Class ImmortalityChecker

java.lang.Object
valorless.rarespawns.ImmortalityChecker
All Implemented Interfaces:
org.bukkit.event.Listener

public class ImmortalityChecker extends Object implements org.bukkit.event.Listener
Debug utility that periodically sweeps cached rare entities and forcibly finalizes any that failed to complete normal death handling.

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:

This class is meant for debugging/recovery of edge cases and should not be relied upon for normal death processing.

  • 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.cachedRares for 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 lastHealthCheck to 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)