Class SpawnerHandlerVanilla

java.lang.Object
studio.magemonkey.genesis.managers.external.spawners.SpawnerHandlerVanilla
All Implemented Interfaces:
ISpawnerHandler

public class SpawnerHandlerVanilla extends Object implements 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 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 entityName as an EntityType (case-insensitive via uppercasing). - If the name is invalid, logs the error and returns null. - If the item lacks BlockStateMeta, returns the original item unchanged. - Otherwise, updates the underlying CreatureSpawner to the parsed type, updates the meta, and sets a display name in the form "{entityName} &7Spawner".

      Note: The provided ItemStack is mutated in place and also returned.

      Specified by:
      transformSpawner in interface ISpawnerHandler
      Parameters:
      monsterSpawner - the spawner ItemStack expected to contain BlockStateMeta
      entityName - the entity type name corresponding to an EntityType constant
      Returns:
      the same ItemStack with updated meta; null if entityName is invalid
    • readSpawner

      public String readSpawner(org.bukkit.inventory.ItemStack monsterSpawner)
      Reads the spawned EntityType from the provided spawner item.

      Behavior: - If the item lacks BlockStateMeta or the spawner has no type, returns an empty string. - Otherwise, returns the EntityType name via toString().

      Specified by:
      readSpawner in interface ISpawnerHandler
      Parameters:
      monsterSpawner - the spawner ItemStack to inspect
      Returns:
      the spawned entity type name, or an empty string if unavailable