Class PreSpawnSpawnerEvent

java.lang.Object
org.bukkit.event.Event
com.kamikazejam.kamicommon.nms.abstraction.event.PreSpawnSpawnerEvent
All Implemented Interfaces:
Cancellable

public class PreSpawnSpawnerEvent extends Event implements Cancellable
Custom event fired before a spawner attempts to spawn an entity.

This event provides cross-version compatibility for spawner monitoring, allowing plugins to intercept and potentially cancel spawner activations before entities are actually created. The implementation varies based on the Minecraft version and available server software.

Version Compatibility:

  • Pre-1.12:
    • 1.8.8: Requires TacoSpigot with net.techcable.tacospigot.event.entity.SpawnerPreSpawnEvent
    • Other versions: Requires Paper with com.destroystokyo.paper.event.entity.SpawnerSpawnEvent
  • 1.13+: Requires Paper with com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent

This event is Cancellable, allowing plugins to prevent specific spawner activations while maintaining compatibility across server versions.

  • Constructor Details

    • PreSpawnSpawnerEvent

      public PreSpawnSpawnerEvent(@NotNull @NotNull Block spawnerBlock, @NotNull @NotNull EntityType type, @Nullable @Nullable Location spawnLocation)
      Constructs a new PreSpawnSpawnerEvent.
      Parameters:
      spawnerBlock - the Block representing the spawner
      type - the EntityType that the spawner is attempting to spawn
      spawnLocation - the Location where the entity will spawn, may be null on older versions or server software
  • Method Details

    • getHandlerList

      public static HandlerList getHandlerList()
    • getHandlers

      public HandlerList getHandlers()
      Specified by:
      getHandlers in class Event
    • getSpawnerBlock

      @NotNull public @NotNull Block getSpawnerBlock()
      Gets the spawner block that is attempting to spawn an entity.
      Returns:
      the Block representing the spawner
    • getSpawnLocation

      @Nullable public @Nullable Location getSpawnLocation()
      Gets the location where the entity will spawn.

      Note: This may be null on older Minecraft versions or server software that doesn't provide spawn location information in their spawner events.

      Returns:
      the spawn Location, or null if not available
    • getType

      @NotNull public @NotNull EntityType getType()
      Gets the type of entity that the spawner is attempting to spawn.
      Returns:
      the EntityType to be spawned