Class ImmortalityChecker
- All Implemented Interfaces:
org.bukkit.event.Listener
Behaviour:
- Runs every second (20 ticks) on the main thread.
- Iterates RareSpawns.cachedRares and inspects each LivingEntity.
- If an entity is dead and is not explicitly tagged "Dead" in its PDC,
it will:
- Attempt to drop loot via
DeathEvent.dropLoot(LivingEntity). - On success, remove the entity from the cache and call
Entity.remove().
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidinit()Starts the periodic sweep task.voidonEntityResurrect(org.bukkit.event.entity.EntityResurrectEvent event) Resets the health check counter for a rare entity upon resurrection.
-
Constructor Details
-
ImmortalityChecker
public ImmortalityChecker()
-
-
Method Details
-
init
protected static void init()Starts the periodic sweep task.Schedules a repeating task that runs every seconds (20 ticks) and checks
RareSpawns.cachedRaresfor entities that are dead but not marked with the"Dead"PDC tag. When such an entity is found, a Discord message is sent,DeathEvent.dropLoot(LivingEntity)is invoked, and on success the entity is removed from both the cache and the world. -
onEntityResurrect
public void onEntityResurrect(org.bukkit.event.entity.EntityResurrectEvent event) Resets the health check counter for a rare entity upon resurrection.When an entity successfully resurrects (e.g., via a totem), this handler checks if it is a rare entity and, if so, resets its health check counter in
lastHealthCheckto zero. This prevents the immortality checker from mistakenly identifying the entity as stuck in a low-health state.- Parameters:
event- the resurrection event fired when an entity would resurrect (e.g., Totem of Undying)
-