Remove class pets on player death.

When a player with pets dies in the arena, we want their pets to be
removed. One could probably argue that the pets _should_ be able to
stick around, but the original intent was for them to be removed
alongside their owner.

Fixes #721
This commit is contained in:
Andreas Troelsen
2022-06-25 17:16:09 +02:00
parent 3e2c614c18
commit 36908cbe85
2 changed files with 7 additions and 3 deletions
@@ -810,6 +810,9 @@ public class ArenaImpl implements Arena
}
leavingPlayers.add(p);
// Remove pets.
monsterManager.removePets(p);
// Clear inventory if player is an arena player, and unmount
if (arenaPlayers.contains(p)) {
unmount(p);
@@ -866,6 +869,9 @@ public class ArenaImpl implements Arena
ArenaPlayerDeathEvent event = new ArenaPlayerDeathEvent(p, this, last);
plugin.getServer().getPluginManager().callEvent(event);
// Remove pets.
monsterManager.removePets(p);
// Clear the player's inventory, and unmount
if (arenaPlayers.remove(p)) {
unmount(p);
@@ -1131,9 +1137,6 @@ public class ArenaImpl implements Arena
}
});
// Remove pets.
monsterManager.removePets(p);
// readyPlayers before lobbyPlayers because of startArena sanity-checks
readyPlayers.remove(p);
specPlayers.remove(p);