bossbar fix??

This commit is contained in:
Chayapak 2023-09-17 08:25:22 +07:00
parent f141b84d49
commit a3d20455b1
2 changed files with 37 additions and 11 deletions

View file

@ -14,6 +14,8 @@ public class BotBossBar extends BossBar {
public final Component secret = Component.text(Math.random() * 69420);
public boolean gotSecret = false;
private final Bot bot;
public String id;
@ -49,6 +51,8 @@ public class BotBossBar extends BossBar {
}
public void setTitle(Component title, boolean force) {
if (!gotSecret) return;
if (ComponentUtilities.isEqual(this.title, title) && !force) return;
if (bot.bossbar.actionBar) {
@ -71,6 +75,8 @@ public class BotBossBar extends BossBar {
}
public void setColor(BossBarColor color, boolean force) {
if (!gotSecret) return;
if (this.color == color && !force) return;
this.color = color;
@ -85,6 +91,8 @@ public class BotBossBar extends BossBar {
}
public void setPlayers(String players) {
if (!gotSecret) return;
if (this.players.equals(players)) return;
this.players = players;
@ -99,6 +107,8 @@ public class BotBossBar extends BossBar {
setDivision(division, false);
}
public void setDivision (BossBarDivision _division, boolean force) {
if (!gotSecret) return;
if (this.division == _division && !force) return;
this.division = _division;
@ -123,6 +133,8 @@ public class BotBossBar extends BossBar {
setValue(value, false);
}
public void setValue (int value, boolean force) {
if (!gotSecret) return;
if (this.value == value && !force) return;
this.value = value;
@ -134,6 +146,8 @@ public class BotBossBar extends BossBar {
public boolean visible () { return visible; }
public void setVisible (boolean visible) {
if (!gotSecret) return;
if (this.visible == visible) return;
this.visible = visible;
@ -148,6 +162,8 @@ public class BotBossBar extends BossBar {
setMax(max, false);
}
public void setMax (long max, boolean force) {
if (!gotSecret) return;
if (this.max == max && !force) return;
this.max = max;

View file

@ -63,9 +63,7 @@ public class BossbarManagerPlugin extends Bot.Listener {
if (ComponentUtilities.isEqual(bossBar.secret, packet.getTitle())) {
bossBars.remove(_bossBar.getKey());
bossBars.put(
packet.getUuid(),
new BotBossBar(
final BotBossBar newBossBar = new BotBossBar(
bossBar.title(),
bossBar.players(),
bossBar.color,
@ -74,7 +72,13 @@ public class BossbarManagerPlugin extends Bot.Listener {
bossBar.max(),
bossBar.value(),
bot
)
);
newBossBar.gotSecret = true;
bossBars.put(
packet.getUuid(),
newBossBar
);
bossBars.get(packet.getUuid()).id = bossBar.id;
@ -117,6 +121,8 @@ public class BossbarManagerPlugin extends Bot.Listener {
botBossBar.setTitle(botBossBar.title, true);
} else if (botBossBar != null && ComponentUtilities.isEqual(botBossBar.secret, packet.getTitle())) {
botBossBar.uuid = packet.getUuid();
botBossBar.gotSecret = true;
}
bossBar.title = packet.getTitle();
@ -147,7 +153,11 @@ public class BossbarManagerPlugin extends Bot.Listener {
final UUID uuid = _bossBar.getKey();
final BotBossBar bossBar = _bossBar.getValue();
if (!serverBossBars.containsKey(uuid)) addBossBar(bossBar.id, bossBar, true);
if (!serverBossBars.containsKey(uuid)) {
bossBar.gotSecret = false;
addBossBar(bossBar.id, bossBar, true);
}
}
}