Skip to content

Commit

Permalink
fix(velocity): bossbar refreshing crashing notchian client
Browse files Browse the repository at this point in the history
Fixes #439
  • Loading branch information
diogotcorreia committed Aug 21, 2024
1 parent ffd7bc4 commit a80c7b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import com.velocitypowered.api.event.connection.PreLoginEvent;
import com.velocitypowered.api.event.player.ServerPostConnectEvent;
import com.velocitypowered.api.event.proxy.ProxyPingEvent;
import com.velocitypowered.api.network.ProtocolVersion;
import com.velocitypowered.api.proxy.server.ServerPing;
import lombok.val;
import net.kyori.adventure.text.Component;
Expand Down Expand Up @@ -50,6 +51,11 @@ public void afterServerConnect(ServerPostConnectEvent e) {
val lp = (VelocityLanguagePlayer) Triton.get().getPlayerManager().get(e.getPlayer().getUniqueId());
VelocityTriton.asVelocity().getBridgeManager().sendPlayerLanguage(lp);

if (lp.getProtocolVersion().compareTo(ProtocolVersion.MINECRAFT_1_20_3) > 0) {
// On 1.20.6 and above, the notchian client crashes if a bossbar that does not exist client-side is updated
lp.clearCachedBossbars();
}

if (Triton.get().getConf().isRunLanguageCommandsOnLogin()) {
lp.executeCommands(serverConnection.getServer());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ Map<UUID, Component> getCachedBossBars() {
return Collections.unmodifiableMap(bossBars);
}

public void clearCachedBossbars() {
bossBars.clear();
}

public void cachePlayerListItem(UUID uuid, Component lastDisplayName) {
playerListItemCache.put(uuid, lastDisplayName);
}
Expand Down

0 comments on commit a80c7b2

Please sign in to comment.