mirror of
https://github.com/garbagemule/MobArena.git
synced 2024-11-26 12:36:00 +01:00
Remove pets in case they die.
This technically can't happen because all pet damage is cancelled, but we never know, and we best be sure to clean up.
This commit is contained in:
parent
cb8983b162
commit
ab031e3e63
@ -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);
|
||||
}
|
||||
|
@ -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<Entity> pets = playerToPets.get(owner);
|
||||
if (pets != null) {
|
||||
pets.remove(pet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Player getOwner(Entity pet) {
|
||||
return petToPlayer.get(pet);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user