[fabric] Prevent NPEs getting client locale.

This commit is contained in:
wizjany 2020-06-26 13:40:06 -04:00
parent 46d3b5caf6
commit 66047ade3d
3 changed files with 3 additions and 3 deletions

View File

@ -35,6 +35,7 @@
import com.sk89q.worldedit.util.HandSide; import com.sk89q.worldedit.util.HandSide;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.WorldEditText; 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.Component;
import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer; import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
@ -134,7 +135,7 @@ public void dispatchCUIEvent(CUIEvent event) {
@Override @Override
public Locale getLocale() { public Locale getLocale() {
return Locale.forLanguageTag(((ExtendedPlayerEntity) this.player).getLanguage().replace("_", "-")); return TextUtils.getLocaleByMinecraftTag(((ExtendedPlayerEntity) this.player).getLanguage());
} }
@Override @Override

View File

@ -20,7 +20,6 @@
package com.sk89q.worldedit.fabric.mixin; package com.sk89q.worldedit.fabric.mixin;
import net.minecraft.network.packet.c2s.play.ClientSettingsC2SPacket; 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.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.gen.Accessor;

View File

@ -36,7 +36,7 @@
@Mixin(ServerPlayerEntity.class) @Mixin(ServerPlayerEntity.class)
public abstract class MixinServerPlayerEntity extends PlayerEntity implements ExtendedPlayerEntity { public abstract class MixinServerPlayerEntity extends PlayerEntity implements ExtendedPlayerEntity {
private String language; private String language = "en_us";
public MixinServerPlayerEntity(World world, BlockPos blockPos, GameProfile gameProfile) { public MixinServerPlayerEntity(World world, BlockPos blockPos, GameProfile gameProfile) {
super(world, blockPos, gameProfile); super(world, blockPos, gameProfile);