3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-27 08:30:09 +01:00

Make bossbar patch a configurable option

Dieser Commit ist enthalten in:
Myles 2016-03-10 13:22:32 +00:00
Ursprung 1bf1e8981c
Commit 83518b92fe
3 geänderte Dateien mit 36 neuen und 29 gelöschten Zeilen

Datei anzeigen

@ -236,6 +236,10 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
return getConfig().getBoolean("hologram-patch", false); return getConfig().getBoolean("hologram-patch", false);
} }
public boolean isBossbarPatch() {
return getConfig().getBoolean("bossbar-patch", true);
}
public double getHologramYOffset() { public double getHologramYOffset() {
return getConfig().getDouble("hologram-y", -1D); return getConfig().getDouble("hologram-y", -1D);
} }

Datei anzeigen

@ -896,35 +896,36 @@ public class OutgoingTransformer {
} }
} }
// TODO: Add config option
// Boss bar // Boss bar
if(type == EntityType.ENDER_DRAGON || type == EntityType.WITHER) { if(plugin.isBossbarPatch()) {
if(entry.getOldID() == 2) { if (type == EntityType.ENDER_DRAGON || type == EntityType.WITHER) {
BossBar bar = bossBarMap.get(entityID); if (entry.getOldID() == 2) {
String title = (String) entry.getValue(); BossBar bar = bossBarMap.get(entityID);
title = title.isEmpty() ? (type == EntityType.ENDER_DRAGON ? "Ender Dragon" : "Wither") : title; String title = (String) entry.getValue();
if(bar == null) { title = title.isEmpty() ? (type == EntityType.ENDER_DRAGON ? "Ender Dragon" : "Wither") : title;
bar = ViaVersion.getInstance().createBossBar(title, BossColor.PURPLE, BossStyle.SOLID); if (bar == null) {
bossBarMap.put(entityID, bar); bar = ViaVersion.getInstance().createBossBar(title, BossColor.PURPLE, BossStyle.SOLID);
bar.addPlayer(info.getPlayer()); bossBarMap.put(entityID, bar);
bar.show(); bar.addPlayer(info.getPlayer());
} else { bar.show();
bar.setTitle((String) entry.getValue()); } else {
} bar.setTitle((String) entry.getValue());
} else if(entry.getOldID() == 6) { }
BossBar bar = bossBarMap.get(entityID); } else if (entry.getOldID() == 6) {
// Make health range between 0 and 1 BossBar bar = bossBarMap.get(entityID);
float maxHealth = type == EntityType.ENDER_DRAGON ? 200.0f : 300.0f; // Make health range between 0 and 1
float health = Math.max(0.0f, Math.min(((float) entry.getValue()) / maxHealth, 1.0f)); float maxHealth = type == EntityType.ENDER_DRAGON ? 200.0f : 300.0f;
System.out.println(health + " " + entry.getValue()); float health = Math.max(0.0f, Math.min(((float) entry.getValue()) / maxHealth, 1.0f));
if(bar == null) { System.out.println(health + " " + entry.getValue());
String title = type == EntityType.ENDER_DRAGON ? "Ender Dragon" : "Wither"; if (bar == null) {
bar = ViaVersion.getInstance().createBossBar(title, health, BossColor.PURPLE, BossStyle.SOLID); String title = type == EntityType.ENDER_DRAGON ? "Ender Dragon" : "Wither";
bossBarMap.put(entityID, bar); bar = ViaVersion.getInstance().createBossBar(title, health, BossColor.PURPLE, BossStyle.SOLID);
bar.addPlayer(info.getPlayer()); bossBarMap.put(entityID, bar);
bar.show(); bar.addPlayer(info.getPlayer());
} else { bar.show();
bar.setHealth(health); } else {
bar.setHealth(health);
}
} }
} }
} }

Datei anzeigen

@ -19,3 +19,5 @@ hologram-patch: false
hologram-y: -1 hologram-y: -1
# Enable player tick simulation, this fixes eating, drinking, nether portals. # Enable player tick simulation, this fixes eating, drinking, nether portals.
simulate-pt: true simulate-pt: true
# Should we patch boss bars so they work? (Default: true, disable if you're having issues)
bossbar-patch: true