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 16:47:48 +02:00
parent 3e2c614c18
commit 36908cbe85
2 changed files with 7 additions and 3 deletions

View File

@ -39,6 +39,7 @@ These changes will (most likely) be included in the next version.
- Players no longer take fall damage when they leave (or get removed from) an arena while falling.
- Players no longer take damage from projectiles shot by pets of other players.
- Normal shulker boxes are now properly removed from inventories of players using the My Items class.
- Class pets are now correctly removed from the arena when their owner dies, rather than when they leave.
- MobArena no longer nags players with the `mobarena.admin.teleport` permission when they engage in a teleport that would have otherwise been blocked.
- MobArena now correctly sets the source property on auto-ignited TNT.

View File

@ -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);