Class SimpleChunkLocation

java.lang.Object
org.kingdoms.constants.land.location.SimpleChunkLocation
All Implemented Interfaces:
Cloneable, org.kingdoms.constants.DataStringRepresentation, org.kingdoms.server.location.BlockPoint2D

public class SimpleChunkLocation extends Object implements Cloneable, org.kingdoms.server.location.BlockPoint2D, org.kingdoms.constants.DataStringRepresentation
  • 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(org.kingdoms.server.location.Location location)
    • of

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

      public static SimpleChunkLocation of(@NonNull org.bukkit.block.Block block)
    • 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

      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.Direction direction)
      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()
    • toLocationXZ

      public org.kingdoms.server.location.BlockVector2 toLocationXZ()
    • 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()
      Specified by:
      getX in interface org.kingdoms.server.location.BlockPoint2D
    • getZ

      public int getZ()
      Specified by:
      getZ in interface org.kingdoms.server.location.BlockPoint2D
    • clone

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

      public org.kingdoms.server.location.BlockVector2 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:
    • toChunk

      public @NonNull org.bukkit.Chunk toChunk()
    • asDataString

      @NotNull public @NotNull String asDataString()
      Specified by:
      asDataString in interface org.kingdoms.constants.DataStringRepresentation
    • fromString

      public static SimpleChunkLocation fromString(@NotNull @NotNull String str)