Class RareSpawnEvent

java.lang.Object
org.bukkit.event.Event
valorless.rarespawns.api.events.RareSpawnEvent

public class RareSpawnEvent extends org.bukkit.event.Event
Event fired when a rare entity is spawned by RareSpawns.

Carries the spawn's unique id, the spawned LivingEntity, its associated EntityData definition, and the Location where it appeared. This event is posted synchronously on the server thread.

Spawn origin: SpawnCause indicates where the spawn originated.

  • SpawnCause.INTERNAL — spawned by RareSpawns' own systems (built-in logic, schedules, config rules, or internal commands).
  • SpawnCause.EXTERNAL — spawned through the RareSpawns public API (typically initiated by another plugin via an API call).
  • SpawnCause.NULL — unknown/unspecified.

Listen to this event to implement custom reactions (e.g., announcements, additional effects, logging, or integrations).

  • Nested Class Summary

    Nested classes/interfaces inherited from class org.bukkit.event.Event

    org.bukkit.event.Event.Result
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    RareSpawnEvent(String id, EntityData data, org.bukkit.entity.LivingEntity rare, org.bukkit.Location location, SpawnCause cause)
    Creates a new RareSpawnEvent.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Fires this RareSpawnEvent via the Bukkit event bus.
    Gets the origin/cause of this spawn.
    Gets the data backing the spawned rare.
    static org.bukkit.event.HandlerList
    Required boilerplate for Bukkit custom events.
    org.bukkit.event.HandlerList
    Required boilerplate for Bukkit custom events.
    Gets the unique id of the rare definition that spawned.
    org.bukkit.Location
    Gets the location where the rare spawned.
    org.bukkit.entity.LivingEntity
    Gets the spawned rare entity instance.

    Methods inherited from class org.bukkit.event.Event

    getEventName, isAsynchronous

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • called

      protected boolean called
  • Constructor Details

    • RareSpawnEvent

      public RareSpawnEvent(String id, EntityData data, org.bukkit.entity.LivingEntity rare, org.bukkit.Location location, SpawnCause cause)
      Creates a new RareSpawnEvent.
      Parameters:
      id - Unique id of the rare definition that spawned.
      data - The configuration/data backing the spawned rare.
      rare - The spawned rare entity instance.
      location - The world location where the rare spawned.
      cause - The origin of the spawn, see SpawnCause for semantics.
  • Method Details

    • callEvent

      public void callEvent()
      Fires this RareSpawnEvent via the Bukkit event bus.

      Calls Bukkit.getPluginManager().callEvent(this) synchronously on the main server thread, notifying all registered listeners. This event is not cancellable.

      This method is single-use. If invoked more than once, it throws an IllegalStateException. After a successful dispatch, the internal called flag is set to true to prevent re-dispatch.

      Only call from the server thread. From asynchronous contexts, schedule a synchronous task first.

      Throws:
      IllegalStateException - if the event has already been dispatched
    • getId

      public String getId()
      Gets the unique id of the rare definition that spawned.
      Returns:
      rare id
    • getRareEntity

      public org.bukkit.entity.LivingEntity getRareEntity()
      Gets the spawned rare entity instance.
      Returns:
      the rare LivingEntity
    • getEntityData

      public EntityData getEntityData()
      Gets the data backing the spawned rare.
      Returns:
      EntityData associated with this spawn
    • getLocation

      public org.bukkit.Location getLocation()
      Gets the location where the rare spawned.
      Returns:
      spawn Location
    • getCause

      public SpawnCause getCause()
      Gets the origin/cause of this spawn.

      INTERNAL = spawned by RareSpawns' internal systems; EXTERNAL = spawned via the public API by an external caller; NULL = unknown.

      Returns:
      SpawnCause describing where the spawn originated
    • getHandlers

      public org.bukkit.event.HandlerList getHandlers()
      Required boilerplate for Bukkit custom events.
      Specified by:
      getHandlers in class org.bukkit.event.Event
    • getHandlerList

      public static org.bukkit.event.HandlerList getHandlerList()
      Required boilerplate for Bukkit custom events.
      Returns:
      static handler list