From d61ad7baeffb1f3d35d05783a8e89ce9c6e35e30 Mon Sep 17 00:00:00 2001 From: Tim203 Date: Sat, 2 Nov 2024 11:48:58 +0100 Subject: [PATCH] Reset the scoreboard in the configuration stage --- .../java/org/geysermc/geyser/session/cache/WorldCache.java | 2 +- .../java/JavaFinishConfigurationPacketTranslator.java | 6 ++++++ .../translator/protocol/java/JavaLoginTranslator.java | 2 -- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/session/cache/WorldCache.java b/core/src/main/java/org/geysermc/geyser/session/cache/WorldCache.java index 5927963c04a..f2198c7dcf6 100644 --- a/core/src/main/java/org/geysermc/geyser/session/cache/WorldCache.java +++ b/core/src/main/java/org/geysermc/geyser/session/cache/WorldCache.java @@ -81,7 +81,7 @@ public WorldCache(GeyserSession session) { resetTitleTimes(false); } - public void removeScoreboard() { + public void resetScoreboard() { scoreboard.removeScoreboard(); scoreboard = new Scoreboard(session); } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaFinishConfigurationPacketTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaFinishConfigurationPacketTranslator.java index 8ade4a1f0d0..f6ed79fd5fa 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaFinishConfigurationPacketTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaFinishConfigurationPacketTranslator.java @@ -45,5 +45,11 @@ public void translate(GeyserSession session, ClientboundFinishConfigurationPacke } session.sendUpstreamPacket(playerListPacket); session.getEntityCache().removeAllPlayerEntities(); + + // while ClientboundLoginPacket holds the level, it doesn't hold the scoreboard. + // The ClientboundStartConfigurationPacket indirectly removes the old scoreboard, + // and this packet indirectly creates the new one. + // This makes this packet a good place to reset the scoreboard. + session.getWorldCache().resetScoreboard(); } } diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaLoginTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaLoginTranslator.java index fb9159c4772..93a7d9a144e 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaLoginTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/java/JavaLoginTranslator.java @@ -71,8 +71,6 @@ public void translate(GeyserSession session, ClientboundLoginPacket packet) { DimensionUtils.fastSwitchDimension(session, fakeDim); } - session.getWorldCache().removeScoreboard(); - // Remove all bossbars session.getEntityCache().removeAllBossBars(); // Remove extra hearts, hunger, etc.