Class RareDeathEvent
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 -
Constructor Summary
ConstructorsConstructorDescriptionRareDeathEvent(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 TypeMethodDescriptionvoidFires this RareDeathEvent via the Bukkit event bus.List<org.bukkit.inventory.ItemStack> getDrops()Gets the item drops associated with this death.Gets the data backing the rare that died.static org.bukkit.event.HandlerListRequired boilerplate for Bukkit custom events.org.bukkit.event.HandlerListRequired boilerplate for Bukkit custom events.getId()Gets the unique id of the rare definition that died.org.bukkit.entity.PlayerGets the player responsible for the kill.org.bukkit.LocationGets the location where the rare died.booleanIndicates whether the death was triggered by a command.Methods inherited from class org.bukkit.event.Event
getEventName, isAsynchronous
-
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 benull.drops- The item drops associated with this death.byCommand-trueif the death was caused via a command;falseotherwise.
-
-
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 internalcalledflag is set totrueto 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
Gets the unique id of the rare definition that died.- Returns:
- rare id
-
getEntityData
Gets the data backing the rare that died.- Returns:
EntityDataassociated 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, ornullif not applicable
-
getDrops
Gets the item drops associated with this death.- Returns:
- list of
ItemStackdrops
-
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:
trueif caused via a command;falseotherwise
-
getHandlers
public org.bukkit.event.HandlerList getHandlers()Required boilerplate for Bukkit custom events.- Specified by:
getHandlersin classorg.bukkit.event.Event
-
getHandlerList
public static org.bukkit.event.HandlerList getHandlerList()Required boilerplate for Bukkit custom events.- Returns:
- static handler list
-