From 83518b92fe17ca949b36c830493adbbd81809686 Mon Sep 17 00:00:00 2001 From: Myles Date: Thu, 10 Mar 2016 13:22:32 +0000 Subject: [PATCH] Make bossbar patch a configurable option --- .../us/myles/ViaVersion/ViaVersionPlugin.java | 4 ++ .../transformers/OutgoingTransformer.java | 57 ++++++++++--------- src/main/resources/config.yml | 4 +- 3 files changed, 36 insertions(+), 29 deletions(-) diff --git a/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java b/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java index 85578f1a1..998ae0b84 100644 --- a/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java +++ b/src/main/java/us/myles/ViaVersion/ViaVersionPlugin.java @@ -236,6 +236,10 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI { return getConfig().getBoolean("hologram-patch", false); } + public boolean isBossbarPatch() { + return getConfig().getBoolean("bossbar-patch", true); + } + public double getHologramYOffset() { return getConfig().getDouble("hologram-y", -1D); } diff --git a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java index 73835ea44..0ff2ebdc7 100644 --- a/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java +++ b/src/main/java/us/myles/ViaVersion/transformers/OutgoingTransformer.java @@ -896,35 +896,36 @@ public class OutgoingTransformer { } } - // TODO: Add config option // Boss bar - if(type == EntityType.ENDER_DRAGON || type == EntityType.WITHER) { - if(entry.getOldID() == 2) { - BossBar bar = bossBarMap.get(entityID); - String title = (String) entry.getValue(); - title = title.isEmpty() ? (type == EntityType.ENDER_DRAGON ? "Ender Dragon" : "Wither") : title; - if(bar == null) { - bar = ViaVersion.getInstance().createBossBar(title, BossColor.PURPLE, BossStyle.SOLID); - bossBarMap.put(entityID, bar); - bar.addPlayer(info.getPlayer()); - bar.show(); - } else { - bar.setTitle((String) entry.getValue()); - } - } else if(entry.getOldID() == 6) { - BossBar bar = bossBarMap.get(entityID); - // Make health range between 0 and 1 - float maxHealth = type == EntityType.ENDER_DRAGON ? 200.0f : 300.0f; - float health = Math.max(0.0f, Math.min(((float) entry.getValue()) / maxHealth, 1.0f)); - System.out.println(health + " " + entry.getValue()); - if(bar == null) { - String title = type == EntityType.ENDER_DRAGON ? "Ender Dragon" : "Wither"; - bar = ViaVersion.getInstance().createBossBar(title, health, BossColor.PURPLE, BossStyle.SOLID); - bossBarMap.put(entityID, bar); - bar.addPlayer(info.getPlayer()); - bar.show(); - } else { - bar.setHealth(health); + if(plugin.isBossbarPatch()) { + if (type == EntityType.ENDER_DRAGON || type == EntityType.WITHER) { + if (entry.getOldID() == 2) { + BossBar bar = bossBarMap.get(entityID); + String title = (String) entry.getValue(); + title = title.isEmpty() ? (type == EntityType.ENDER_DRAGON ? "Ender Dragon" : "Wither") : title; + if (bar == null) { + bar = ViaVersion.getInstance().createBossBar(title, BossColor.PURPLE, BossStyle.SOLID); + bossBarMap.put(entityID, bar); + bar.addPlayer(info.getPlayer()); + bar.show(); + } else { + bar.setTitle((String) entry.getValue()); + } + } else if (entry.getOldID() == 6) { + BossBar bar = bossBarMap.get(entityID); + // Make health range between 0 and 1 + float maxHealth = type == EntityType.ENDER_DRAGON ? 200.0f : 300.0f; + float health = Math.max(0.0f, Math.min(((float) entry.getValue()) / maxHealth, 1.0f)); + System.out.println(health + " " + entry.getValue()); + if (bar == null) { + String title = type == EntityType.ENDER_DRAGON ? "Ender Dragon" : "Wither"; + bar = ViaVersion.getInstance().createBossBar(title, health, BossColor.PURPLE, BossStyle.SOLID); + bossBarMap.put(entityID, bar); + bar.addPlayer(info.getPlayer()); + bar.show(); + } else { + bar.setHealth(health); + } } } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index dab6e0d51..c85bb1725 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -18,4 +18,6 @@ hologram-patch: false # This is the offset, should work as default when enabled. hologram-y: -1 # Enable player tick simulation, this fixes eating, drinking, nether portals. -simulate-pt: true \ No newline at end of file +simulate-pt: true +# Should we patch boss bars so they work? (Default: true, disable if you're having issues) +bossbar-patch: true \ No newline at end of file