Class SimpleChunkLocation

java.lang.Object
org.kingdoms.constants.land.location.SimpleChunkLocation
All Implemented Interfaces:
Cloneable

public class SimpleChunkLocation extends Object implements Cloneable
  • Constructor Details

    • SimpleChunkLocation

      public SimpleChunkLocation(@NonNull String world, int x, int z)
  • Method Details

    • of

      public static SimpleChunkLocation of(@NonNull org.bukkit.Chunk chunk)
    • of

      public static SimpleChunkLocation of(@NonNull org.kingdoms.server.location.ImmutableLocation location)
    • of

      public static SimpleChunkLocation of(@NonNull org.bukkit.Location location)
    • of

      public static SimpleChunkLocation of(@NonNull org.bukkit.block.Block block)
    • fromString

      public static @NonNull SimpleChunkLocation fromString(@NonNull String chunk)
      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

      public static Supplier<SimpleChunkLocation> resolve(org.bukkit.block.Block block)
    • resolve

      public static Supplier<SimpleChunkLocation> resolve(org.bukkit.entity.Entity entity)
    • equalsIgnoreWorld

      public boolean equalsIgnoreWorld(SimpleChunkLocation chunk)
    • getRelative

      public SimpleChunkLocation getRelative(int x, int z)
      Returns:
      a copy.
      See Also:
    • getRelative

      public SimpleChunkLocation getRelative(org.kingdoms.server.location.Compass compass)
      Since:
      1.16.20.1
      See Also:
    • isInChunk

      public boolean isInChunk(@NonNull SimpleLocation location)
    • isInChunk

      public boolean isInChunk(@NonNull org.bukkit.Location location)
    • distance

      public double distance(@NonNull SimpleChunkLocation chunk)
    • distanceIgnoreWorld

      public double distanceIgnoreWorld(@NonNull SimpleChunkLocation chunk)
      Multiplication of two integers are never greater than a long. Because {@link Integer#MAX_VALUE} * {@link Integer#MAX_VALUE} < {@link Long#MAX_VALUE} Which is 4611686000000000000 < 9,223,372,036,854,775,807
    • getCenterLocation

      public @NonNull org.bukkit.Location getCenterLocation()
    • getCenterLocation

      public @NonNull org.bukkit.Location getCenterLocation(double y)
    • getSimpleLocation

      public @NonNull SimpleLocation getSimpleLocation(int blockX, int blockY, int blockZ)
    • getWorld

      public @NonNull String getWorld()
    • getBukkitWorld

      public @NonNull org.bukkit.World getBukkitWorld()
    • getX

      public int getX()
    • getZ

      public int getZ()
    • clone

      public @NonNull SimpleChunkLocation clone()
      Overrides:
      clone in class Object
    • worldlessWrapper

      public SimpleChunkLocation.WorldlessWrapper worldlessWrapper()
      Used for performance purposes for hashed collections.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getLand

      public @Nullable Land getLand()
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • getPlayers

      public List<org.bukkit.entity.Player> 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

      public SimpleChunkLocation[] getChunksAround(int radius, boolean includingSelf)
    • getChunksAround

      public SimpleChunkLocation[] getChunksAround(int radius)
    • findFromSurroundingChunks

      public <T> T findFromSurroundingChunks(int radius, Function<SimpleChunkLocation,T> predicate)
    • anySurroundingChunks

      public boolean anySurroundingChunks(int radius, Predicate<SimpleChunkLocation> predicate)
    • findFromSurroundingChunks

      public <T> T findFromSurroundingChunks(int radius, T defaultValue, Function<SimpleChunkLocation,T> predicate)
    • toString

      public String toString()
      Used for data serialization
      Overrides:
      toString in class Object
      See Also:
    • getCompressedData

      public @NonNull String getCompressedData()
    • toChunk

      public @NonNull org.bukkit.Chunk toChunk()