Class SimpleChunkLocation
java.lang.Object
org.kingdoms.constants.land.location.SimpleChunkLocation
- All Implemented Interfaces:
Cloneable
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleananySurroundingChunks(int radius, Predicate<SimpleChunkLocation> predicate) static 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 @NonNull SimpleChunkLocationfromString(@NonNull String chunk) This is only used for data deserialization.@NonNull org.bukkit.World@NonNull org.bukkit.Location@NonNull org.bukkit.LocationgetCenterLocation(double y) getChunksAround(int radius) getChunksAround(int radius, boolean includingSelf) @NonNull String@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.Compass compass) @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.block.Block block) static SimpleChunkLocationof(@NonNull org.bukkit.Chunk chunk) static SimpleChunkLocationof(@NonNull org.bukkit.Location location) static SimpleChunkLocationof(@NonNull org.kingdoms.server.location.ImmutableLocation location) static Supplier<SimpleChunkLocation>resolve(org.bukkit.block.Block block) static Supplier<SimpleChunkLocation>resolve(org.bukkit.entity.Entity entity) @NonNull org.bukkit.ChunktoChunk()toString()Used for data serializationUsed for performance purposes for hashed collections.
-
Constructor Details
-
SimpleChunkLocation
-
-
Method Details
-
of
-
of
public static SimpleChunkLocation of(@NonNull org.kingdoms.server.location.ImmutableLocation location) -
of
-
of
-
fromString
This is only used for data deserialization.- See Also:
-
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() -
getCenterLocation
public @NonNull org.bukkit.Location getCenterLocation(double y) -
getSimpleLocation
-
getWorld
-
getBukkitWorld
public @NonNull org.bukkit.World getBukkitWorld() -
getX
public int getX() -
getZ
public int getZ() -
clone
-
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 -
getCompressedData
-
toChunk
public @NonNull org.bukkit.Chunk toChunk()
-