some fixes (but not all)
we still have the title self care problem which is prob the most noticeable
This commit is contained in:
parent
69713502e4
commit
0bf87c008a
1 changed files with 90 additions and 70 deletions
|
@ -7,6 +7,7 @@ import com.github.steveice10.packetlib.packet.Packet;
|
|||
import land.chipmunk.chayapak.chomens_bot.Bot;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.BossBar;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.BotBossBar;
|
||||
import land.chipmunk.chayapak.chomens_bot.data.chat.MutablePlayerListEntry;
|
||||
import land.chipmunk.chayapak.chomens_bot.util.ComponentUtilities;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
@ -32,6 +33,13 @@ public class BossbarManagerPlugin extends Bot.Listener {
|
|||
this.bot = bot;
|
||||
|
||||
bot.addListener(this);
|
||||
|
||||
bot.players().addListener(new PlayersPlugin.Listener() {
|
||||
@Override
|
||||
public void playerJoined(MutablePlayerListEntry target) {
|
||||
BossbarManagerPlugin.this.playerJoined();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,6 +48,7 @@ public class BossbarManagerPlugin extends Bot.Listener {
|
|||
}
|
||||
|
||||
public void packetReceived(ClientboundBossEventPacket packet) {
|
||||
try {
|
||||
switch (packet.getAction()) {
|
||||
case ADD -> {
|
||||
final Map<UUID, BotBossBar> mapCopy = new HashMap<>(bossBars);
|
||||
|
@ -133,6 +142,17 @@ public class BossbarManagerPlugin extends Bot.Listener {
|
|||
bossBar.health = packet.getHealth();
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void playerJoined () {
|
||||
for (Map.Entry<UUID, BotBossBar> _bossBar : bossBars.entrySet()) {
|
||||
final BotBossBar bossBar = _bossBar.getValue();
|
||||
|
||||
bossBar.setPlayers(bossBar.players);
|
||||
}
|
||||
}
|
||||
|
||||
public void add (String name, BotBossBar bossBar) {
|
||||
|
|
Loading…
Reference in a new issue