Clean up miniboss mobs after their chunk unloads

This commit is contained in:
AlexTheCoder 2016-07-27 04:43:00 -04:00
parent 85cf005eba
commit ea3cb36d3a
1 changed files with 15 additions and 0 deletions

View File

@ -1,5 +1,7 @@
package mineplex.game.clans.clans.nether.miniboss;
import java.util.Arrays;
import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent;
import mineplex.game.clans.clans.ClansManager;
@ -12,6 +14,7 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
/**
* Base class for nether minibosses
@ -90,6 +93,18 @@ public abstract class NetherMiniBoss<Mob extends LivingEntity> implements Listen
}
}
@EventHandler
public void onUnload(ChunkUnloadEvent event)
{
if (Arrays.asList(event.getChunk().getEntities()).contains(_entity))
{
HandlerList.unregisterAll(this);
_entity.remove();
customDespawn();
return;
}
}
@EventHandler
public void onUpdate(UpdateEvent event)
{