From 967261a98ad2e43b7076de87681838a1b9e5018c Mon Sep 17 00:00:00 2001 From: "Lukas Rieger (Blue)" Date: Sun, 21 Jul 2024 09:52:47 +0200 Subject: [PATCH] Fix exception when a player joins the server on fabric-1.20 --- .../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-1.20/src/main/java/de/bluecolored/bluemap/fabric/FabricMod.java b/implementations/fabric-1.20/src/main/java/de/bluecolored/bluemap/fabric/FabricMod.java index 2a40f4b9..c4bc0ad8 100644 --- a/implementations/fabric-1.20/src/main/java/de/bluecolored/bluemap/fabric/FabricMod.java +++ b/implementations/fabric-1.20/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-1.20/src/main/java/de/bluecolored/bluemap/fabric/FabricPlayer.java b/implementations/fabric-1.20/src/main/java/de/bluecolored/bluemap/fabric/FabricPlayer.java index 6dcf2428..692256dd 100644 --- a/implementations/fabric-1.20/src/main/java/de/bluecolored/bluemap/fabric/FabricPlayer.java +++ b/implementations/fabric-1.20/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;