Class SpawnerHandlerVanilla
java.lang.Object
studio.magemonkey.genesis.managers.external.spawners.SpawnerHandlerVanilla
- All Implemented Interfaces:
ISpawnerHandler
Vanilla implementation of
ISpawnerHandler that uses the Bukkit API to
read and write the spawned EntityType of a spawner ItemStack.
This handler operates directly on BlockStateMeta and the embedded
CreatureSpawner block state.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionreadSpawner(org.bukkit.inventory.ItemStack monsterSpawner) Reads the spawnedEntityTypefrom the provided spawner item.org.bukkit.inventory.ItemStacktransformSpawner(org.bukkit.inventory.ItemStack monsterSpawner, String entityName) Transforms the provided spawner item to spawn the given entity type.
-
Constructor Details
-
SpawnerHandlerVanilla
public SpawnerHandlerVanilla()
-
-
Method Details
-
transformSpawner
public org.bukkit.inventory.ItemStack transformSpawner(org.bukkit.inventory.ItemStack monsterSpawner, String entityName) Transforms the provided spawner item to spawn the given entity type.Behavior: - Parses
entityNameas anEntityType(case-insensitive via uppercasing). - If the name is invalid, logs the error and returnsnull. - If the item lacksBlockStateMeta, returns the original item unchanged. - Otherwise, updates the underlyingCreatureSpawnerto the parsed type, updates the meta, and sets a display name in the form "{entityName} &7Spawner".Note: The provided
ItemStackis mutated in place and also returned.- Specified by:
transformSpawnerin interfaceISpawnerHandler- Parameters:
monsterSpawner- the spawnerItemStackexpected to containBlockStateMetaentityName- the entity type name corresponding to anEntityTypeconstant- Returns:
- the same
ItemStackwith updated meta;nullifentityNameis invalid
-
readSpawner
Reads the spawnedEntityTypefrom the provided spawner item.Behavior: - If the item lacks
BlockStateMetaor the spawner has no type, returns an empty string. - Otherwise, returns theEntityTypename viatoString().- Specified by:
readSpawnerin interfaceISpawnerHandler- Parameters:
monsterSpawner- the spawnerItemStackto inspect- Returns:
- the spawned entity type name, or an empty string if unavailable
-