Skip to content

Commit

Permalink
Revert "Update MyListener.java"
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MrBsng committed May 11, 2023
1 parent dd9e675 commit 5a6ef2d
Showing 1 changed file with 25 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static void main(String[] args) {
static HashMap<Player, BossBar> bossBarMap = new HashMap<>();
static HashMap<Player, Boolean> showDebugScreenMap = new HashMap<>();
private static int alternatingTicks = 0; // offsets the bukkitscheduler period every interval.
//default values although the config will override theese.
private static boolean changedDimensionsEvent;
private int particleLevel = 2;
private int particleMultiplier = 4;
private int maxParticleLevel = 4;
Expand Down Expand Up @@ -97,10 +97,17 @@ public static boolean isGeyserPlayer(Player player) {

@EventHandler
public void onPlayerMove(PlayerMoveEvent e) {
alternatingTicks = 0;
Player player = e.getPlayer();
updateInfo(player, e.getTo());
}

@EventHandler
public void onDimensionChange(PlayerChangedWorldEvent e) {
changedDimensionsEvent = true;
alternatingTicks = 0;
}

public void updateInfo(Player player, Location location) {
if (!isGeyserPlayer(player))
return;
Expand All @@ -126,8 +133,24 @@ public void updateInfo(Player player, Location location) {
currentBossBar = Bukkit.createBossBar(getBossBarTitle(player, location), BarColor.BLUE, BarStyle.SOLID);
currentBossBar.addPlayer(player);
bossBarMap.put(player, currentBossBar);
} else
} else {
// When switching dimensions, bossbar does not appear, re-enable when switching
// dimensions only.
// If bossbar immediately does not appear, stand still for 8 intervals. (2
// seconds)
if (changedDimensionsEvent == true && alternatingTicks == 8) {
currentBossBar.removePlayer(player);
currentBossBar.addPlayer(player);
changedDimensionsEvent = false;
}

currentBossBar.setTitle(getBossBarTitle(player, location));
if (alternatingTicks > 0 && alternatingTicks % 5 == 0) {
currentBossBar.setColor(BarColor.GREEN);
} else {
currentBossBar.setColor(BarColor.BLUE);
}
}

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

0 comments on commit 5a6ef2d

Please sign in to comment.