Class StructureHandler

java.lang.Object
com.ryandw11.structure.structure.StructureHandler

public class StructureHandler extends Object
This handler manages the list of active structures.

You can access this handler from CustomStructuresAPI.getStructureHandler() or CustomStructures.getStructureHandler().

Note: Do not store a long term instance of this class as it can be invalidated when the /cstruct reload command is done.

  • Constructor Details

  • Method Details

    • getStructures

      public List<Structure> getStructures()
      Get the list of structures.

      This list is read only and cannot be modified.

      Returns:
      The list of structures.
    • getStructure

      public Structure getStructure(String name)
      Get structure by name
      Parameters:
      name - The name
      Returns:
      The structure. (Returns null if the structure is not found).
    • getStructure

      public Structure getStructure(int i)
      Get the structure by a number.
      Parameters:
      i - The number
      Returns:
      The structure.
    • getStructureNames

      public List<String> getStructureNames()
      Get the names of the structures.
      Returns:
      The names of the structures.
    • getSpawnedStructures

      public SortedMap<Pair<org.bukkit.Location,​Long>,​Structure> getSpawnedStructures()
      Get the Map of spawned structures.

      Note: This map is not synchronized by default and can be modified on a different thread.

      Returns:
      The list of spawned structures.
    • putSpawnedStructure

      public void putSpawnedStructure(org.bukkit.Location loc, Structure struct)
      Add a structure to the list of spawned structures.

      This feature must be enabled via the config.

      Note: This will not spawn in a structure, only add one to the list of spawned structures (seen by /cstruct nearby). Use Structure.spawn(Location) to spawn a structure in the world.

      Parameters:
      loc - The location.
      struct - The structure.
    • validDistance

      public boolean validDistance(Structure struct, org.bukkit.Location location)
      Calculate if the structure is far enough away from other structures.
      Parameters:
      struct - The structure to calculate that for.
      location - The location that the structure is spawning.
      Returns:
      If the distance is valid according to its config.
    • validSameDistance

      public boolean validSameDistance(Structure struct, org.bukkit.Location location)
      Calculate if the structure is far enough away from other structures of the same type.
      Parameters:
      struct - The structure to calculate.
      location - The location where the structure would spawn.
      Returns:
      If the distance is valid according to its config.
    • getStructureDatabaseHandler

      public Optional<StructureDatabaseHandler> getStructureDatabaseHandler()
      Get the structure database handler.

      This feature must be enabled via the config.

      Returns:
      An Optional of the StructureDatabaseHandler.
    • cleanup

      public void cleanup()
      Shutdown internal processes.