From 66047ade3d90b3ffc3a8e878c336da31e6f4fe08 Mon Sep 17 00:00:00 2001 From: wizjany Date: Fri, 26 Jun 2020 13:40:06 -0400 Subject: [PATCH] [fabric] Prevent NPEs getting client locale. --- .../src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java | 3 ++- .../fabric/mixin/AccessorClientSettingsC2SPacket.java | 1 - .../sk89q/worldedit/fabric/mixin/MixinServerPlayerEntity.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java index f95caf1cc..4dcf20340 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricPlayer.java @@ -35,6 +35,7 @@ import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.formatting.WorldEditText; +import com.sk89q.worldedit.util.formatting.component.TextUtils; import com.sk89q.worldedit.util.formatting.text.Component; import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer; import com.sk89q.worldedit.world.World; @@ -134,7 +135,7 @@ public void dispatchCUIEvent(CUIEvent event) { @Override public Locale getLocale() { - return Locale.forLanguageTag(((ExtendedPlayerEntity) this.player).getLanguage().replace("_", "-")); + return TextUtils.getLocaleByMinecraftTag(((ExtendedPlayerEntity) this.player).getLanguage()); } @Override diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorClientSettingsC2SPacket.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorClientSettingsC2SPacket.java index 3bc2e440f..5f1dbf089 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorClientSettingsC2SPacket.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorClientSettingsC2SPacket.java @@ -20,7 +20,6 @@ package com.sk89q.worldedit.fabric.mixin; import net.minecraft.network.packet.c2s.play.ClientSettingsC2SPacket; -import net.minecraft.server.world.ThreadedAnvilChunkStorage; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.gen.Accessor; diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinServerPlayerEntity.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinServerPlayerEntity.java index e0844c921..586577a67 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinServerPlayerEntity.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/MixinServerPlayerEntity.java @@ -36,7 +36,7 @@ @Mixin(ServerPlayerEntity.class) public abstract class MixinServerPlayerEntity extends PlayerEntity implements ExtendedPlayerEntity { - private String language; + private String language = "en_us"; public MixinServerPlayerEntity(World world, BlockPos blockPos, GameProfile gameProfile) { super(world, blockPos, gameProfile);