Class RareDeathEvent

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

public class RareDeathEvent extends org.bukkit.event.Event
Event fired when a rare entity dies in RareSpawns.

Carries the rare's unique id, its EntityData definition, the Location where it died, the killing Entity (may be null), the list of ItemStack drops attributed to the death, and a flag indicating whether the death was triggered by a command (e.g., admin) rather than standard gameplay. This event is posted synchronously on the server thread.

Listen to this event to implement custom reactions (e.g., announcements, custom loot logic, 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
    RareDeathEvent(String id, EntityData data, org.bukkit.Location location, org.bukkit.entity.Player killer, List<org.bukkit.inventory.ItemStack> drops, boolean byCommand)
    Creates a new RareDeathEvent.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Fires this RareDeathEvent via the Bukkit event bus.
    List<org.bukkit.inventory.ItemStack>
    Gets the item drops associated with this death.
    Gets the data backing the rare that died.
    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 died.
    org.bukkit.entity.Player
    Gets the player responsible for the kill.
    org.bukkit.Location
    Gets the location where the rare died.
    boolean
    Indicates whether the death was triggered by a command.

    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

    • RareDeathEvent

      public RareDeathEvent(String id, EntityData data, org.bukkit.Location location, org.bukkit.entity.Player killer, List<org.bukkit.inventory.ItemStack> drops, boolean byCommand)
      Creates a new RareDeathEvent.
      Parameters:
      id - Unique id of the rare definition that died.
      data - The configuration/data associated with the rare.
      location - The world location where the rare died.
      killer - The player responsible for the kill; may be null.
      drops - The item drops associated with this death.
      byCommand - true if the death was caused via a command; false otherwise.
  • Method Details

    • callEvent

      public void callEvent()
      Fires this RareDeathEvent 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 died.
      Returns:
      rare id
    • getEntityData

      public EntityData getEntityData()
      Gets the data backing the rare that died.
      Returns:
      EntityData associated with this death
    • getLocation

      public org.bukkit.Location getLocation()
      Gets the location where the rare died.
      Returns:
      death Location
    • getKiller

      public org.bukkit.entity.Player getKiller()
      Gets the player responsible for the kill.
      Returns:
      killer Player, or null if not applicable
    • getDrops

      public List<org.bukkit.inventory.ItemStack> getDrops()
      Gets the item drops associated with this death.
      Returns:
      list of ItemStack drops
    • isByCommand

      public boolean isByCommand()
      Indicates whether the death was triggered by a command.

      Useful to distinguish admin-initiated removals from natural or combat deaths.

      Returns:
      true if caused via a command; false otherwise
    • 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