diff --git a/src/main/java/com/garbagemule/MobArena/ArenaListener.java b/src/main/java/com/garbagemule/MobArena/ArenaListener.java index 24f1aff..67ef4ed 100644 --- a/src/main/java/com/garbagemule/MobArena/ArenaListener.java +++ b/src/main/java/com/garbagemule/MobArena/ArenaListener.java @@ -494,6 +494,9 @@ public class ArenaListener if (event instanceof PlayerDeathEvent) { onPlayerDeath((PlayerDeathEvent) event, (Player) event.getEntity()); } + else if (monsters.hasPet(event.getEntity())) { + monsters.removePet(event.getEntity()); + } else if (monsters.removeMonster(event.getEntity())) { onMonsterDeath(event); } diff --git a/src/main/java/com/garbagemule/MobArena/MonsterManager.java b/src/main/java/com/garbagemule/MobArena/MonsterManager.java index 98b2ac6..26e467b 100644 --- a/src/main/java/com/garbagemule/MobArena/MonsterManager.java +++ b/src/main/java/com/garbagemule/MobArena/MonsterManager.java @@ -131,6 +131,18 @@ public class MonsterManager return petToPlayer.containsKey(e); } + public void removePet(Entity pet) { + pet.remove(); + + Player owner = petToPlayer.remove(pet); + if (owner != null) { + Set pets = playerToPets.get(owner); + if (pets != null) { + pets.remove(pet); + } + } + } + public Player getOwner(Entity pet) { return petToPlayer.get(pet); }