mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2025-02-02 12:51:22 +01:00
Make bossbar patch a configurable option
This commit is contained in:
parent
1bf1e8981c
commit
83518b92fe
@ -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);
|
||||
}
|
||||
|
@ -896,14 +896,14 @@ public class OutgoingTransformer {
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Add config option
|
||||
// Boss bar
|
||||
if(type == EntityType.ENDER_DRAGON || type == EntityType.WITHER) {
|
||||
if(entry.getOldID() == 2) {
|
||||
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) {
|
||||
if (bar == null) {
|
||||
bar = ViaVersion.getInstance().createBossBar(title, BossColor.PURPLE, BossStyle.SOLID);
|
||||
bossBarMap.put(entityID, bar);
|
||||
bar.addPlayer(info.getPlayer());
|
||||
@ -911,13 +911,13 @@ public class OutgoingTransformer {
|
||||
} else {
|
||||
bar.setTitle((String) entry.getValue());
|
||||
}
|
||||
} else if(entry.getOldID() == 6) {
|
||||
} 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) {
|
||||
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);
|
||||
@ -929,6 +929,7 @@ public class OutgoingTransformer {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private UUID getUUID(int id) {
|
||||
|
@ -19,3 +19,5 @@ hologram-patch: false
|
||||
hologram-y: -1
|
||||
# Enable player tick simulation, this fixes eating, drinking, nether portals.
|
||||
simulate-pt: true
|
||||
# Should we patch boss bars so they work? (Default: true, disable if you're having issues)
|
||||
bossbar-patch: true
|
Loading…
Reference in New Issue
Block a user