Class Tracker<S extends Tracked<K>,K extends WorldKey>

java.lang.Object
net.paulem.arcana.regions.Tracker<S,K>
Type Parameters:
S - the type of the object to track

public abstract class Tracker<S extends Tracked<K>,K extends WorldKey> extends Object
A class to extend that tracks all the specified S type in the server.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new tracker with an empty GlobalBlockContainer.
  • Method Summary

    Modifier and Type
    Method
    Description
    Retrieves the tracked object registered at the given key, if any.
    abstract void
    handleChunkLoad(org.bukkit.Chunk chunk)
    Called when a chunk is loaded, allowing implementations to populate the tracker with the tracked objects contained in that chunk.
    void
    handleChunkUnload(org.bukkit.Chunk chunk)
    Called when a chunk is unloaded.
    void
    registerHolder(S tracked)
    Registers a tracked object in the global container, using its own key.
    void
    removeHolder(S tracked)
    Removes a tracked object from the global container, using its own key.
    void
    saveChunk(org.bukkit.Chunk chunk)
    Saves all tracked objects held within the given chunk by invoking Tracked.onUnload() on each of them.
    void
    saveChunk(org.bukkit.Chunk chunk, Consumer<Holder<S,K>> callback)
    Invokes the given callback for every holder tracked within the given chunk.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • getHolderAt

      @Nullable public S getHolderAt(K key)
      Retrieves the tracked object registered at the given key, if any.
      Parameters:
      key - the key to look up
      Returns:
      the tracked object at the key, or null if none is registered
    • registerHolder

      public void registerHolder(S tracked)
      Registers a tracked object in the global container, using its own key.
      Parameters:
      tracked - the object to register
    • removeHolder

      public void removeHolder(S tracked)
      Removes a tracked object from the global container, using its own key.
      Parameters:
      tracked - the object to remove
    • handleChunkLoad

      public abstract void handleChunkLoad(org.bukkit.Chunk chunk)
      Called when a chunk is loaded, allowing implementations to populate the tracker with the tracked objects contained in that chunk.
      Parameters:
      chunk - the chunk that was loaded
    • handleChunkUnload

      public void handleChunkUnload(org.bukkit.Chunk chunk)
      Called when a chunk is unloaded. Saves all tracked objects held in the chunk and removes the chunk's container from its world container.
      Parameters:
      chunk - the chunk that was unloaded
    • saveChunk

      public void saveChunk(org.bukkit.Chunk chunk)
      Saves all tracked objects held within the given chunk by invoking Tracked.onUnload() on each of them.
      Parameters:
      chunk - the chunk whose tracked objects should be saved
    • saveChunk

      public void saveChunk(org.bukkit.Chunk chunk, Consumer<Holder<S,K>> callback)
      Invokes the given callback for every holder tracked within the given chunk. Does nothing if the chunk's world or chunk container isn't tracked.
      Parameters:
      chunk - the chunk whose holders should be visited
      callback - the action to perform for each holder in the chunk