Clean up miniboss mobs after their chunk unloads
This commit is contained in:
parent
85cf005eba
commit
ea3cb36d3a
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue