Skip to content

Commit 5a6ef2d

Browse files
committed
Revert "Update MyListener.java"
This reverts commit 4f35e50. Because Geyser does not have a sufficient way to readd the debug boss bar, but atleast we know what code to deprecate if a solution in geyser comes.
1 parent dd9e675 commit 5a6ef2d

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

src/main/java/com/gmail/heathmitchell27/debuginfobe/MyListener.java

+25-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static void main(String[] args) {
5050
static HashMap<Player, BossBar> bossBarMap = new HashMap<>();
5151
static HashMap<Player, Boolean> showDebugScreenMap = new HashMap<>();
5252
private static int alternatingTicks = 0; // offsets the bukkitscheduler period every interval.
53-
//default values although the config will override theese.
53+
private static boolean changedDimensionsEvent;
5454
private int particleLevel = 2;
5555
private int particleMultiplier = 4;
5656
private int maxParticleLevel = 4;
@@ -97,10 +97,17 @@ public static boolean isGeyserPlayer(Player player) {
9797

9898
@EventHandler
9999
public void onPlayerMove(PlayerMoveEvent e) {
100+
alternatingTicks = 0;
100101
Player player = e.getPlayer();
101102
updateInfo(player, e.getTo());
102103
}
103104

105+
@EventHandler
106+
public void onDimensionChange(PlayerChangedWorldEvent e) {
107+
changedDimensionsEvent = true;
108+
alternatingTicks = 0;
109+
}
110+
104111
public void updateInfo(Player player, Location location) {
105112
if (!isGeyserPlayer(player))
106113
return;
@@ -126,8 +133,24 @@ public void updateInfo(Player player, Location location) {
126133
currentBossBar = Bukkit.createBossBar(getBossBarTitle(player, location), BarColor.BLUE, BarStyle.SOLID);
127134
currentBossBar.addPlayer(player);
128135
bossBarMap.put(player, currentBossBar);
129-
} else
136+
} else {
137+
// When switching dimensions, bossbar does not appear, re-enable when switching
138+
// dimensions only.
139+
// If bossbar immediately does not appear, stand still for 8 intervals. (2
140+
// seconds)
141+
if (changedDimensionsEvent == true && alternatingTicks == 8) {
142+
currentBossBar.removePlayer(player);
143+
currentBossBar.addPlayer(player);
144+
changedDimensionsEvent = false;
145+
}
146+
130147
currentBossBar.setTitle(getBossBarTitle(player, location));
148+
if (alternatingTicks > 0 && alternatingTicks % 5 == 0) {
149+
currentBossBar.setColor(BarColor.GREEN);
150+
} else {
151+
currentBossBar.setColor(BarColor.BLUE);
152+
}
153+
}
131154

132155
if (targetBlock == null || targetBlock.getLocation() == null) {
133156
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent("-"));

0 commit comments

Comments
 (0)