From 6d1a68e2d7db1f6d9bb01c6d78f8a5fda91ef7ca Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Mon, 6 Apr 2020 13:21:16 +1200 Subject: [PATCH] Fix bossbars wanting to stick around --- .../disguise/utilities/DisguiseUtilities.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java index fa5368cd..92a210a2 100644 --- a/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java +++ b/src/main/java/me/libraryaddict/disguise/utilities/DisguiseUtilities.java @@ -34,6 +34,8 @@ import me.libraryaddict.disguise.utilities.translations.LibsMsg; import org.apache.commons.lang.StringUtils; import org.apache.logging.log4j.util.Strings; import org.bukkit.*; +import org.bukkit.boss.BossBar; +import org.bukkit.boss.KeyedBossBar; import org.bukkit.entity.*; import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; @@ -943,6 +945,19 @@ public class DisguiseUtilities { registerAllExtendedNames(board); registerNoName(board); } + + Iterator bars = Bukkit.getBossBars(); + ArrayList barList = new ArrayList<>(); + bars.forEachRemaining(barList::add); + + for (KeyedBossBar bar : barList) { + if (!bar.getKey().getNamespace().equalsIgnoreCase("libsdisguises")) { + continue; + } + + bar.removeAll(); + Bukkit.removeBossBar(bar.getKey()); + } } public static boolean isDisguiseInUse(Disguise disguise) { @@ -2224,6 +2239,8 @@ public class DisguiseUtilities { case BAT: if (entity instanceof LivingEntity) return yMod + ((LivingEntity) entity).getEyeHeight(); + + return yMod; case MINECART: case MINECART_COMMAND: case MINECART_CHEST: