BossBars are no longer supported in 1.12 due to api restrictions
This commit is contained in:
		| @@ -444,6 +444,14 @@ public class DisguiseConfig { | ||||
|  | ||||
|         try { | ||||
|             setNotifyBar(NotifyBar.valueOf(config.getString("NotifyBar").toUpperCase())); | ||||
|  | ||||
|             if (getNotifyBar() == NotifyBar.BOSS_BAR) { | ||||
|                 DisguiseUtilities.getLogger().warning( | ||||
|                         "BossBars hasn't been implemented properly in 1.12 due to api restrictions, falling back to " + | ||||
|                                 "ACTION_BAR"); | ||||
|  | ||||
|                 setNotifyBar(NotifyBar.ACTION_BAR); | ||||
|             } | ||||
|         } | ||||
|         catch (Exception ex) { | ||||
|             DisguiseUtilities.getLogger() | ||||
|   | ||||
| @@ -20,6 +20,7 @@ import me.libraryaddict.disguise.events.DisguiseEvent; | ||||
| import me.libraryaddict.disguise.events.UndisguiseEvent; | ||||
| import me.libraryaddict.disguise.utilities.DisguiseUtilities; | ||||
| import me.libraryaddict.disguise.utilities.LibsPremium; | ||||
| import me.libraryaddict.disguise.utilities.reflection.NmsVersion; | ||||
| import me.libraryaddict.disguise.utilities.reflection.ReflectionManager; | ||||
| import me.libraryaddict.disguise.utilities.translations.LibsMsg; | ||||
| import net.md_5.bungee.api.ChatMessageType; | ||||
| @@ -186,7 +187,8 @@ public abstract class Disguise { | ||||
|     } | ||||
|  | ||||
|     private void makeBossBar() { | ||||
|         if (getNotifyBar() != DisguiseConfig.NotifyBar.BOSS_BAR || !(getEntity() instanceof Player)) { | ||||
|         if (getNotifyBar() != DisguiseConfig.NotifyBar.BOSS_BAR || !NmsVersion.v1_13.isSupported() || | ||||
|                 !(getEntity() instanceof Player)) { | ||||
|             return; | ||||
|         } | ||||
|  | ||||
| @@ -803,11 +805,13 @@ public abstract class Disguise { | ||||
|         getEntity().setMetadata("LastDisguise", | ||||
|                 new FixedMetadataValue(LibsDisguises.getInstance(), System.currentTimeMillis())); | ||||
|  | ||||
|         BossBar bar = Bukkit.getBossBar(getBossBar()); | ||||
|         if (NmsVersion.v1_13.isSupported()) { | ||||
|             BossBar bar = Bukkit.getBossBar(getBossBar()); | ||||
|  | ||||
|         if (bar != null) { | ||||
|             bar.removeAll(); | ||||
|             Bukkit.removeBossBar(getBossBar()); | ||||
|             if (bar != null) { | ||||
|                 bar.removeAll(); | ||||
|                 Bukkit.removeBossBar(getBossBar()); | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         return true; | ||||
|   | ||||
| @@ -967,17 +967,19 @@ public class DisguiseUtilities { | ||||
|             registerNoName(board); | ||||
|         } | ||||
|  | ||||
|         Iterator<KeyedBossBar> bars = Bukkit.getBossBars(); | ||||
|         ArrayList<KeyedBossBar> barList = new ArrayList<>(); | ||||
|         bars.forEachRemaining(barList::add); | ||||
|         if (NmsVersion.v1_13.isSupported()) { | ||||
|             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; | ||||
|             for (KeyedBossBar bar : barList) { | ||||
|                 if (!bar.getKey().getNamespace().equalsIgnoreCase("libsdisguises")) { | ||||
|                     continue; | ||||
|                 } | ||||
|  | ||||
|                 bar.removeAll(); | ||||
|                 Bukkit.removeBossBar(bar.getKey()); | ||||
|             } | ||||
|  | ||||
|             bar.removeAll(); | ||||
|             Bukkit.removeBossBar(bar.getKey()); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -127,6 +127,7 @@ HearSelfDisguise: true | ||||
|  | ||||
| # When disguised, should a message be displayed to the player? If so, where? | ||||
| # The message can be customized in translations | ||||
| # BOSS_BAR is not supported in 1.12! | ||||
| # NONE, BOSS_BAR, ACTION_BAR | ||||
| NotifyBar: ACTION_BAR | ||||
| # If using boss bar, these two options come into play | ||||
|   | ||||
		Reference in New Issue
	
	Block a user