From 36908cbe853d8a456c9e6fea31a5233ca7e41fac Mon Sep 17 00:00:00 2001 From: Andreas Troelsen Date: Sat, 25 Jun 2022 16:47:48 +0200 Subject: [PATCH] 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 --- changelog.md | 1 + src/main/java/com/garbagemule/MobArena/ArenaImpl.java | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/changelog.md b/changelog.md index 5e02f26..bf0bfd6 100644 --- a/changelog.md +++ b/changelog.md @@ -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. diff --git a/src/main/java/com/garbagemule/MobArena/ArenaImpl.java b/src/main/java/com/garbagemule/MobArena/ArenaImpl.java index 7697b71..c32b2e7 100644 --- a/src/main/java/com/garbagemule/MobArena/ArenaImpl.java +++ b/src/main/java/com/garbagemule/MobArena/ArenaImpl.java @@ -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);