Package valorless.rarespawns.events
Class ResurrectEvent
java.lang.Object
valorless.rarespawns.events.ResurrectEvent
- All Implemented Interfaces:
org.bukkit.event.Listener
Bukkit listener that enables RareSpawns "totem" items to resurrect entities.
Behavior:
- Players: Scans the entire inventory for a rare item whose
ItemData.totemflag is true. IfItemData.totemHeldis true, the item must be held in the main- or off-hand. When a valid item is found, the event is allowed to proceed (viasetCancelled(false)), an optional sound (ItemData.totemSound) is played at the player's location, and exactly one item is consumed. - Non-player entities: Checks the entity's equipment (off-hand then main-hand then armor) for a rare totem item and applies the same allow/play/consume behavior.
init() during plugin enable.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidinit()Registers this listener with Bukkit's PluginManager.voidonEntityResurrect(org.bukkit.event.entity.EntityResurrectEvent event) HandlesEntityResurrectEventto allow rare items configured as totems to trigger resurrection.
-
Constructor Details
-
ResurrectEvent
public ResurrectEvent()
-
-
Method Details
-
init
public static void init()Registers this listener with Bukkit's PluginManager. Call from your plugin'sonEnable(). -
onEntityResurrect
public void onEntityResurrect(org.bukkit.event.entity.EntityResurrectEvent event) HandlesEntityResurrectEventto allow rare items configured as totems to trigger resurrection.This method ensures the event is not cancelled when a valid rare totem is present, optionally plays a configured sound, and consumes one unit of the totem item. For players, the entire inventory is scanned; when
totemHeldis required, only main/off-hand items qualify. For non-players, only equipments are checked.- Parameters:
event- the resurrection event fired when an entity would resurrect (e.g., Totem of Undying)
-