Class SimpleChunkLocation
java.lang.Object
org.kingdoms.constants.land.location.SimpleChunkLocation
- All Implemented Interfaces:
Cloneable,org.kingdoms.constants.DataStringRepresentation,org.kingdoms.server.location.BlockPoint2D
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleananySurroundingChunks(int radius, Predicate<SimpleChunkLocation> predicate) @NotNull Stringstatic intcalculateBorderSize(int n) Calculates the amount of chunks contained in a square if the square's borders were n long.@NonNull SimpleChunkLocationclone()doubledistance(@NonNull SimpleChunkLocation chunk) doubledistanceIgnoreWorld(@NonNull SimpleChunkLocation chunk) Multiplication of two integers are never greater than a long.booleanboolean@Nullable SimpleChunkLocationfindFarthestChunk(Collection<SimpleChunkLocation> locations, boolean ignoreWorld) Compares the provided locations with the current location and finds the one with the most distance.<T> TfindFromSurroundingChunks(int radius, Function<SimpleChunkLocation, T> predicate) <T> TfindFromSurroundingChunks(int radius, T defaultValue, Function<SimpleChunkLocation, T> predicate) static SimpleChunkLocationfromString(@NotNull String str) @NonNull org.bukkit.World@NonNull org.bukkit.Location@NonNull org.bukkit.LocationgetCenterLocation(double y) getChunksAround(int radius) getChunksAround(int radius, boolean includingSelf) @Nullable LandgetLand()List<org.bukkit.entity.Player> Gets a list of players that are inside this chunk.getRelative(int x, int z) getRelative(org.kingdoms.server.location.Direction direction) @NonNull SimpleLocationgetSimpleLocation(int blockX, int blockY, int blockZ) @NonNull StringgetWorld()intgetX()intgetZ()inthashCode()booleanisInChunk(@NonNull org.bukkit.Location location) booleanisInChunk(@NonNull SimpleLocation location) static SimpleChunkLocationof(@NonNull org.bukkit.Chunk chunk) static SimpleChunkLocationof(@NonNull org.bukkit.Location location) static SimpleChunkLocationof(@NonNull org.bukkit.block.Block block) static SimpleChunkLocationof(org.kingdoms.server.location.Location location) static Supplier<SimpleChunkLocation> resolve(org.bukkit.block.Block block) static Supplier<SimpleChunkLocation> resolve(org.bukkit.entity.Entity entity) org.kingdoms.server.location.BlockVector2@NonNull org.bukkit.ChunktoChunk()org.kingdoms.server.location.BlockVector2toString()Used for data serializationorg.kingdoms.server.location.BlockVector2Used for performance purposes for hashed collections.
-
Constructor Details
-
SimpleChunkLocation
-
-
Method Details
-
of
-
of
-
of
-
of
-
toBlockVector
public org.kingdoms.server.location.BlockVector2 toBlockVector() -
calculateBorderSize
public static int calculateBorderSize(int n) Calculates the amount of chunks contained in a square if the square's borders were n long. -
resolve
-
resolve
-
equalsIgnoreWorld
-
getRelative
- Returns:
- a copy.
- See Also:
-
getRelative
- Since:
- 1.16.20.1
- See Also:
-
isInChunk
-
isInChunk
public boolean isInChunk(@NonNull org.bukkit.Location location) -
distance
-
distanceIgnoreWorld
Multiplication of two integers are never greater than a long. Because{@link Integer#MAX_VALUE} * {@link Integer#MAX_VALUE} < {@link Long#MAX_VALUE}Which is4611686000000000000 < 9,223,372,036,854,775,807 -
getCenterLocation
public @NonNull org.bukkit.Location getCenterLocation() -
toLocationXZ
public org.kingdoms.server.location.BlockVector2 toLocationXZ() -
getCenterLocation
public @NonNull org.bukkit.Location getCenterLocation(double y) -
getSimpleLocation
-
getWorld
-
getBukkitWorld
public @NonNull org.bukkit.World getBukkitWorld() -
getX
public int getX()- Specified by:
getXin interfaceorg.kingdoms.server.location.BlockPoint2D
-
getZ
public int getZ()- Specified by:
getZin interfaceorg.kingdoms.server.location.BlockPoint2D
-
clone
-
worldlessWrapper
public org.kingdoms.server.location.BlockVector2 worldlessWrapper()Used for performance purposes for hashed collections. -
hashCode
public int hashCode() -
getLand
-
equals
-
getPlayers
Gets a list of players that are inside this chunk. -
findFarthestChunk
public @Nullable SimpleChunkLocation findFarthestChunk(Collection<SimpleChunkLocation> locations, boolean ignoreWorld) Compares the provided locations with the current location and finds the one with the most distance.- Parameters:
locations- a list of chunks to find the farthest chunk from.ignoreWorld- whether the provided locations are ensured to be in the same world. If set to false, it first checks if there are any chunks that are in the same world as the current chunk, and if not, picks a random chunk from another world.- Returns:
- the farthest chunk or null if locations is empty or for some reasons the list only contains the current chunk.
-
getChunksAround
-
getChunksAround
-
findFromSurroundingChunks
-
anySurroundingChunks
-
findFromSurroundingChunks
public <T> T findFromSurroundingChunks(int radius, T defaultValue, Function<SimpleChunkLocation, T> predicate) -
toString
Used for data serialization -
toChunk
public @NonNull org.bukkit.Chunk toChunk() -
asDataString
- Specified by:
asDataStringin interfaceorg.kingdoms.constants.DataStringRepresentation
-
fromString
-