Class StructureHandler
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 Summary
ConstructorDescriptionStructureHandler(List<String> stringStructs, CustomStructures cs)
Constructor for the structure handler. -
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanup()
Shutdown internal processes.Get the Map of spawned structures.getStructure(int i)
Get the structure by a number.getStructure(String name)
Get structure by nameGet the structure database handler.Get the names of the structures.Get the list of structures.void
putSpawnedStructure(org.bukkit.Location loc, Structure struct)
Add a structure to the list of spawned structures.boolean
validDistance(Structure struct, org.bukkit.Location location)
Calculate if the structure is far enough away from other structures.boolean
validSameDistance(Structure struct, org.bukkit.Location location)
Calculate if the structure is far enough away from other structures of the same type.
-
Constructor Details
-
StructureHandler
Constructor for the structure handler.This is for internal use only. Use
CustomStructuresAPI.getStructureHandler()
orCustomStructures.getStructureHandler()
instead.- Parameters:
stringStructs
- The list of structures.cs
- The plugin.
-
-
Method Details
-
getStructures
Get the list of structures.This list is read only and cannot be modified.
- Returns:
- The list of structures.
-
getStructure
Get structure by name- Parameters:
name
- The name- Returns:
- The structure. (Returns null if the structure is not found).
-
getStructure
Get the structure by a number.- Parameters:
i
- The number- Returns:
- The structure.
-
getStructureNames
Get the names of the structures.- Returns:
- The names of the structures.
-
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
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
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
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
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.
-