From cca1fbc8265c650666a9e56ce21dd1bbae1a0b61 Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Tue, 4 Jun 2024 11:47:08 +0200 Subject: [PATCH] Fix exception when a player joins the server on fabric --- .../java/de/bluecolored/bluemap/fabric/FabricMod.java | 2 +- .../de/bluecolored/bluemap/fabric/FabricPlayer.java | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricMod.java b/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricMod.java index ada6b842..2d2c3fa1 100644 --- a/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricMod.java +++ b/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricMod.java @@ -189,7 +189,7 @@ public Optional getModsFolder() { public void onPlayerJoin(MinecraftServer server, ServerPlayerEntity playerInstance) { if (this.serverInstance != server) return; - FabricPlayer player = new FabricPlayer(playerInstance.getUuid(), this); + FabricPlayer player = new FabricPlayer(playerInstance, this); onlinePlayerMap.put(player.getUuid(), player); onlinePlayerList.add(player); } diff --git a/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricPlayer.java b/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricPlayer.java index 6dcf2428..692256dd 100644 --- a/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricPlayer.java +++ b/implementations/fabric/src/main/java/de/bluecolored/bluemap/fabric/FabricPlayer.java @@ -64,11 +64,11 @@ public class FabricPlayer implements Player { private final FabricMod mod; - public FabricPlayer(UUID playerUuid, FabricMod mod) { - this.uuid = playerUuid; + public FabricPlayer(ServerPlayerEntity player, FabricMod mod) { + this.uuid = player.getUuid(); this.mod = mod; - update(); + update(player); } @Override @@ -131,6 +131,10 @@ public void update() { ServerPlayerEntity player = server.getPlayerManager().getPlayer(uuid); if (player == null) return; + update(player); + } + + public void update(ServerPlayerEntity player) { this.gamemode = GAMEMODE_MAP.get(player.interactionManager.getGameMode()); if (this.gamemode == null) this.gamemode = Gamemode.SURVIVAL;