Fix bossbars wanting to stick around

This commit is contained in:
libraryaddict 2020-04-06 13:21:16 +12:00
parent 6379ecaa8c
commit 6d1a68e2d7
No known key found for this signature in database
GPG Key ID: 052E4FBCD257AEA4

View File

@ -34,6 +34,8 @@ import me.libraryaddict.disguise.utilities.translations.LibsMsg;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.apache.logging.log4j.util.Strings; import org.apache.logging.log4j.util.Strings;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.boss.BossBar;
import org.bukkit.boss.KeyedBossBar;
import org.bukkit.entity.*; import org.bukkit.entity.*;
import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -943,6 +945,19 @@ public class DisguiseUtilities {
registerAllExtendedNames(board); registerAllExtendedNames(board);
registerNoName(board); registerNoName(board);
} }
Iterator<KeyedBossBar> bars = Bukkit.getBossBars();
ArrayList<KeyedBossBar> 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) { public static boolean isDisguiseInUse(Disguise disguise) {
@ -2224,6 +2239,8 @@ public class DisguiseUtilities {
case BAT: case BAT:
if (entity instanceof LivingEntity) if (entity instanceof LivingEntity)
return yMod + ((LivingEntity) entity).getEyeHeight(); return yMod + ((LivingEntity) entity).getEyeHeight();
return yMod;
case MINECART: case MINECART:
case MINECART_COMMAND: case MINECART_COMMAND:
case MINECART_CHEST: case MINECART_CHEST: