From 5a6ef2d19f444d0b18d929510de019b8d199db3c Mon Sep 17 00:00:00 2001 From: Brian Date: Wed, 10 May 2023 21:53:32 -0700 Subject: [PATCH] Revert "Update MyListener.java" This reverts commit 4f35e50590bc9bc37f25c2ace761fd4c5fa491c3. 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. --- .../debuginfobe/MyListener.java | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/heathmitchell27/debuginfobe/MyListener.java b/src/main/java/com/gmail/heathmitchell27/debuginfobe/MyListener.java index d4126a6..2effc2a 100644 --- a/src/main/java/com/gmail/heathmitchell27/debuginfobe/MyListener.java +++ b/src/main/java/com/gmail/heathmitchell27/debuginfobe/MyListener.java @@ -50,7 +50,7 @@ public static void main(String[] args) { static HashMap bossBarMap = new HashMap<>(); static HashMap 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; @@ -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; @@ -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("-"));