Class WorldCoord

java.lang.Object
com.palmergames.bukkit.towny.object.Coord
com.palmergames.bukkit.towny.object.WorldCoord
Direct Known Subclasses:
CellBorder

public class WorldCoord extends Coord
  • Constructor Details

    • WorldCoord

      public WorldCoord(String worldName, int x, int z)
    • WorldCoord

      public WorldCoord(String worldName, Coord coord)
    • WorldCoord

      public WorldCoord(String worldName, UUID worldUUID, int x, int z)
    • WorldCoord

      public WorldCoord(String worldName, UUID worldUUID, Coord coord)
    • WorldCoord

      public WorldCoord(@NotNull @NotNull org.bukkit.World world, int x, int z)
    • WorldCoord

      public WorldCoord(@NotNull @NotNull org.bukkit.World world, Coord coord)
    • WorldCoord

      public WorldCoord(WorldCoord worldCoord)
  • Method Details

    • getWorldName

      public String getWorldName()
    • getCoord

      public Coord getCoord()
    • parseWorldCoord

      public static WorldCoord parseWorldCoord(org.bukkit.entity.Entity entity)
    • parseWorldCoord

      public static WorldCoord parseWorldCoord(String worldName, int blockX, int blockZ)
    • parseWorldCoord

      public static WorldCoord parseWorldCoord(org.bukkit.Location loc)
    • parseWorldCoord

      public static WorldCoord parseWorldCoord(org.bukkit.block.Block block)
    • add

      public WorldCoord add(int xOffset, int zOffset)
      Overrides:
      add in class Coord
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Coord
    • equals

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

      public String toString()
      Overrides:
      toString in class Coord
    • getBukkitWorld

      @Nullable public @Nullable org.bukkit.World getBukkitWorld()
      Shortcut for Bukkit.getWorld(worldName)
      Returns:
      the relevant World instance
    • getTownyWorld

      @Nullable public @Nullable TownyWorld getTownyWorld()
      Returns:
      the relevant TownyWorld instance or null.
    • getTownBlock

      public TownBlock getTownBlock() throws NotRegisteredException
      Shortcut for TownyUniverse.getInstance().getTownBlock(WorldCoord).
      Returns:
      the relevant TownBlock instance.
      Throws:
      NotRegisteredException - If there is no TownBlock at this WorldCoord.
    • getTownBlockOrNull

      @Nullable public @Nullable TownBlock getTownBlockOrNull()
      Relatively safe to use if hasTownBlock() has already been checked and returned true.
      Returns:
      TownBlock at this WorldCoord or null;
    • hasTownBlock

      public boolean hasTownBlock()
    • hasTown

      public boolean hasTown(Town town)
    • isWilderness

      public boolean isWilderness()
      Identical to !hasTownBlock(), but is better readable.
      Returns:
      Whether this townblock is not claimed.
    • loadChunks

      public void loadChunks()
      Loads the chunks represented by a WorldCoord. Creates a PluginChunkTicket so that the WorldCoord will remain loaded, even when no players are present.

      Uses PaperLib's getChunkAtAsync when Paper is present.

    • unloadChunks

      public void unloadChunks()
      Unloads the chunks presented by a WorldCoord. Removes a PluginChunkTicket so that the WorldCoord will no longer remain loaded.

      Uses PaperLib's getChunkAtAsync when Paper is present.

    • getChunks

      public @Unmodifiable Collection<CompletableFuture<org.bukkit.Chunk>> getChunks()
      Loads and returns the chunk(s) inside this WorldCoord.

      Chunks are loaded async on servers using paper.

      Returns:
      An unmodifiable collection of chunk futures.
    • getChunkPositions

      protected Collection<Pair<Integer,Integer>> getChunkPositions()
    • getChunkPositions

      protected Collection<Pair<Integer,Integer>> getChunkPositions(int cellSize)
      Parameters:
      cellSize - The current Coord.getCellSize()
      Returns:
      A collection of all chunk coords that are contained within this worldcoord for the given cell size
    • isFullyLoaded

      public boolean isFullyLoaded()
      Returns:
      Whether all chunks contained in this worldcoord are loaded.
    • getBoundingBox

      public org.bukkit.util.BoundingBox getBoundingBox()
      Returns:
      Return a Bukkit bounding box containg the space of the WorldCoord.
    • getLowerMostCornerLocation

      public org.bukkit.Location getLowerMostCornerLocation()
      Returns:
      Location of the lower-most corner of a WorldCoord.
    • getUpperMostCornerLocation

      public org.bukkit.Location getUpperMostCornerLocation()
      Returns:
      Location of the upper-most corner of a WorldCoord.
    • getTownOrNull

      @Nullable public @Nullable Town getTownOrNull()
      Relatively safe to use if hasTownBlock() has already been used.
      Returns:
      Town at this WorldCoord or null;
    • cellChanged

      public static boolean cellChanged(org.bukkit.Location from, org.bukkit.Location to)
      Checks that locations are in different cells without allocating any garbage to the heap.
      Parameters:
      from - Original location
      to - Next location
      Returns:
      whether the locations are in different cells
    • getCardinallyAdjacentWorldCoords

      public List<WorldCoord> getCardinallyAdjacentWorldCoords(boolean... includeOrdinalFlag)
    • canBeStolen

      public boolean canBeStolen()