From ded86d48722718be0c0f50bc77a3d6353d1b587c Mon Sep 17 00:00:00 2001 From: Matthew Miller Date: Mon, 18 Nov 2019 19:50:52 +1000 Subject: [PATCH] Fixed issues brought up in review --- .../bukkit/BukkitBlockCommandSender.java | 3 ++- .../worldedit/bukkit/BukkitCommandInspector.java | 5 +++-- .../worldedit/bukkit/BukkitCommandSender.java | 3 ++- .../worldedit/bukkit/BukkitServerInterface.java | 5 +++-- .../sk89q/worldedit/cli/CLICommandSender.java | 3 ++- .../com/sk89q/worldedit/cli/CLIWorldEdit.java | 6 +++--- worldedit-core/build.gradle.kts | 12 ++++++------ .../com/sk89q/worldedit/LocalConfiguration.java | 3 +++ .../sk89q/worldedit/command/BrushCommands.java | 2 +- .../sk89q/worldedit/command/GeneralCommands.java | 7 ++++--- .../worldedit/util/PropertiesConfiguration.java | 7 +++++++ .../sk89q/worldedit/util/YAMLConfiguration.java | 8 ++++++++ .../sk89q/worldedit/util/io/ResourceLoader.java | 16 +++++++++------- .../util/translation/TranslationManager.java | 15 +++++++-------- .../src/main/resources/lang/strings.json | 9 ++++++--- .../fabric/mixin/AccessorServerPlayerEntity.java | 2 +- .../fabric/mixin/MixinServerPlayerEntity.java | 1 - .../worldedit/sponge/SpongeCommandSender.java | 3 ++- .../sponge/config/ConfigurateConfiguration.java | 7 +++++++ 19 files changed, 76 insertions(+), 41 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java index e5545a804..549afab2b 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCommandSender.java @@ -21,6 +21,7 @@ package com.sk89q.worldedit.bukkit; import static com.google.common.base.Preconditions.checkNotNull; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor; import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extent.Extent; @@ -98,7 +99,7 @@ public class BukkitBlockCommandSender extends AbstractNonPlayerActor implements @Override public Locale getLocale() { - return Locale.US; + return WorldEdit.getInstance().getConfiguration().defaultLocale; } @Override diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java index a314b4855..d40d94cb4 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandInspector.java @@ -20,6 +20,7 @@ package com.sk89q.worldedit.bukkit; import com.sk89q.bukkit.util.CommandInspector; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.Actor; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -53,7 +54,7 @@ class BukkitCommandInspector implements CommandInspector { public String getShortText(Command command) { Optional mapping = dispatcher.getCommand(command.getName()); if (mapping.isPresent()) { - return reduceToText(mapping.get().getDescription(), Locale.US); + return reduceToText(mapping.get().getDescription(), WorldEdit.getInstance().getConfiguration().defaultLocale); } else { logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); return "Help text not available"; @@ -64,7 +65,7 @@ class BukkitCommandInspector implements CommandInspector { public String getFullText(Command command) { Optional mapping = dispatcher.getCommand(command.getName()); if (mapping.isPresent()) { - return reduceToText(mapping.get().getFullHelp(), Locale.US); + return reduceToText(mapping.get().getFullHelp(), WorldEdit.getInstance().getConfiguration().defaultLocale); } else { logger.warn("BukkitCommandInspector doesn't know how about the command '" + command + "'"); return "Help text not available"; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java index 33dc3594c..bff893151 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitCommandSender.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.bukkit; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.AbstractNonPlayerActor; import com.sk89q.worldedit.session.SessionKey; import com.sk89q.worldedit.util.auth.AuthorizationException; @@ -114,7 +115,7 @@ public class BukkitCommandSender extends AbstractNonPlayerActor { @Override public Locale getLocale() { - return Locale.US; + return WorldEdit.getInstance().getConfiguration().defaultLocale; } @Override diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java index 5a9ca9b93..4adc32fc7 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitServerInterface.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.bukkit; import com.sk89q.bukkit.util.CommandInfo; import com.sk89q.bukkit.util.CommandRegistration; import com.sk89q.worldedit.LocalConfiguration; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.command.util.PermissionCondition; import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.extension.platform.Actor; @@ -170,8 +171,8 @@ public class BukkitServerInterface implements MultiUserPlatform { command.getAliases().stream() ).toArray(String[]::new); // TODO Handle localisation correctly - return new CommandInfo(reduceToText(command.getUsage(), Locale.US), - reduceToText(command.getDescription(), Locale.US), aliases, + return new CommandInfo(reduceToText(command.getUsage(), WorldEdit.getInstance().getConfiguration().defaultLocale), + reduceToText(command.getDescription(), WorldEdit.getInstance().getConfiguration().defaultLocale), aliases, inspector, permissionsArray); }).collect(Collectors.toList())); } diff --git a/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLICommandSender.java b/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLICommandSender.java index 2170cf17c..93b52f6ae 100644 --- a/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLICommandSender.java +++ b/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLICommandSender.java @@ -21,6 +21,7 @@ package com.sk89q.worldedit.cli; import static com.google.common.base.Preconditions.checkNotNull; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.session.SessionKey; @@ -141,7 +142,7 @@ public class CLICommandSender implements Actor { @Override public Locale getLocale() { - return Locale.getDefault(); + return WorldEdit.getInstance().getConfiguration().defaultLocale; } @Override diff --git a/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIWorldEdit.java b/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIWorldEdit.java index 9bff097c1..56853ffe3 100644 --- a/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIWorldEdit.java +++ b/worldedit-cli/src/main/java/com/sk89q/worldedit/cli/CLIWorldEdit.java @@ -32,7 +32,7 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; import com.sk89q.worldedit.registry.state.Property; -import com.sk89q.worldedit.util.formatting.text.TextComponent; +import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockCategory; import com.sk89q.worldedit.world.block.BlockState; @@ -238,13 +238,13 @@ public class CLIWorldEdit { while (scanner.hasNextLine()) { String line = scanner.nextLine(); if (line.equals("stop")) { - commandSender.printInfo(TextComponent.of("Stopping!")); + commandSender.printInfo(TranslatableComponent.of("worldedit.cli.stopping")); break; } CommandEvent event = new CommandEvent(commandSender, line); WorldEdit.getInstance().getEventBus().post(event); if (!event.isCancelled()) { - commandSender.printError(TextComponent.of("Unknown command!")); + commandSender.printError(TranslatableComponent.of("worldedit.cli.unknown-command")); } else { saveAllWorlds(false); } diff --git a/worldedit-core/build.gradle.kts b/worldedit-core/build.gradle.kts index 7eb0f967e..b65b4f58f 100644 --- a/worldedit-core/build.gradle.kts +++ b/worldedit-core/build.gradle.kts @@ -95,20 +95,20 @@ if (project.hasProperty(crowdinApiKey)) { apiKey = "${project.property(crowdinApiKey)}" projectId = "worldedit-core" files = arrayOf( - object { - var name = "strings.json" - var source = "$projectDir/src/main/resources/lang/strings.json" - } + object { + var name = "strings.json" + var source = "${file("src/main/resources/lang/strings.json")}" + } ) } tasks.named("crowdinDownload") { apiKey = "${project.property(crowdinApiKey)}" - destination = "$projectDir/src/main/resources/lang" + destination = "${file("build/resources/main/lang")}" projectId = "worldedit-core" } - tasks.named("processResources").configure { + tasks.named("classes").configure { dependsOn("crowdinDownload") } } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java index 0b042c8bb..de5be392f 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/LocalConfiguration.java @@ -29,6 +29,7 @@ import com.sk89q.worldedit.world.snapshot.SnapshotRepository; import java.io.File; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Objects; import java.util.Set; @@ -76,6 +77,8 @@ public abstract class LocalConfiguration { public boolean allowSymlinks = false; public boolean serverSideCUI = true; public boolean extendedYLimit = false; + public String defaultLocaleName = "default"; + public Locale defaultLocale = Locale.getDefault(); protected String[] getDefaultDisallowedBlocks() { List blockTypes = Lists.newArrayList( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java index 3fa686190..1d4a9a861 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BrushCommands.java @@ -118,7 +118,7 @@ public class BrushCommands { tool.setBrush(new SphereBrush(), "worldedit.brush.sphere"); } - player.printInfo(TranslatableComponent.of("worldedit.brush.sphere.equip", TextComponent.of((int) radius))); + player.printInfo(TranslatableComponent.of("worldedit.brush.sphere.equip", TextComponent.of(String.format("%.0f", radius)))); } @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java index 55cde4d5f..2c15e120d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java @@ -96,7 +96,7 @@ public class GeneralCommands { session.setBlockChangeLimit(limit); Component component = TextComponent.empty().append(TranslatableComponent.of("worldedit.limit.set", TextComponent.of(limit))); if (limit != config.defaultChangeLimit) { - component.append(TranslatableComponent.of("worldedit.limit.return-to-default", TextColor.GRAY)); + component.append(TextComponent.space()).append(TranslatableComponent.of("worldedit.limit.return-to-default", TextColor.GRAY)); } actor.printInfo(component); } @@ -180,7 +180,8 @@ public class GeneralCommands { } boolean useServerCui = session.shouldUseServerCUI(); if (drawSelection != null && drawSelection == useServerCui) { - player.printError(TranslatableComponent.of(useServerCui ? "worldedit.drawsel.enabled.already" : "worldedit.drawsel.disabled.already")); + player.printError(TranslatableComponent.of("worldedit.drawsel." + (useServerCui ? "enabled" : "disabled") + ".already")); + return; } if (useServerCui) { @@ -284,7 +285,7 @@ public class GeneralCommands { return; } if (blocksOnly && itemsOnly) { - actor.printError(TranslatableComponent.of("worldedit.searchitem.b-and-i")); + actor.printError(TranslatableComponent.of("worldedit.searchitem.either-b-or-i")); return; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java index 7953c4d31..ff96ee16a 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/PropertiesConfiguration.java @@ -39,6 +39,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.util.Arrays; import java.util.HashSet; +import java.util.Locale; import java.util.Properties; import java.util.Set; @@ -119,6 +120,12 @@ public class PropertiesConfiguration extends LocalConfiguration { allowSymlinks = getBool("allow-symbolic-links", allowSymlinks); serverSideCUI = getBool("server-side-cui", serverSideCUI); extendedYLimit = getBool("extended-y-limit", extendedYLimit); + defaultLocaleName = getString("default-locale", defaultLocaleName); + if (defaultLocaleName.equals("default")) { + defaultLocale = Locale.getDefault(); + } else { + defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-')); + } LocalSession.MAX_HISTORY_SIZE = Math.max(15, getInt("history-size", 15)); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java index be676b132..4110b9599 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/YAMLConfiguration.java @@ -30,6 +30,7 @@ import org.slf4j.Logger; import java.io.IOException; import java.util.HashSet; +import java.util.Locale; /** * A less simple implementation of {@link LocalConfiguration} @@ -125,6 +126,13 @@ public class YAMLConfiguration extends LocalConfiguration { shellSaveType = type.isEmpty() ? null : type; extendedYLimit = config.getBoolean("compat.extended-y-limit", false); + + defaultLocaleName = config.getString("default-locale", defaultLocaleName); + if (defaultLocaleName.equals("default")) { + defaultLocale = Locale.getDefault(); + } else { + defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-')); + } } public void unload() { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ResourceLoader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ResourceLoader.java index 1f3555353..0ce49b115 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ResourceLoader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/io/ResourceLoader.java @@ -27,16 +27,19 @@ public class ResourceLoader { private ResourceLoader() { } + private static URL getResourceForgeHack(String location) throws IOException { + return new URL("modjar://worldedit/" + location); + } + public static URL getResource(Class clazz, String name) throws IOException { URL url = clazz.getResource(name); if (url == null) { try { - return new URL("modjar://worldedit/" + clazz.getName().substring(0, clazz.getName().lastIndexOf('.')).replace(".", "/") + "/" - + name); + return getResourceForgeHack(clazz.getName().substring(0, clazz.getName().lastIndexOf('.')).replace(".", "/") + + "/" + name); } catch (Exception e) { - // Not forge. + throw new IOException("Could not find " + name); } - throw new IOException("Could not find " + name); } return url; } @@ -45,11 +48,10 @@ public class ResourceLoader { URL url = ResourceLoader.class.getResource("/" + name); if (url == null) { try { - return new URL("modjar://worldedit/" + name); + return getResourceForgeHack(name); } catch (Exception e) { - // Not forge. + throw new IOException("Could not find " + name); } - throw new IOException("Could not find " + name); } return url; } diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/util/translation/TranslationManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/util/translation/TranslationManager.java index 1a2dbf9b8..c253d3091 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/util/translation/TranslationManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/util/translation/TranslationManager.java @@ -30,7 +30,10 @@ import com.sk89q.worldedit.util.formatting.text.renderer.FriendlyComponentRender import com.sk89q.worldedit.util.io.ResourceLoader; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.lang.reflect.Type; import java.net.URL; import java.nio.charset.StandardCharsets; @@ -81,19 +84,15 @@ public class TranslationManager { return translations; } - private Map parseTranslationFile(File file) throws IOException { - return filterTranslations(gson.fromJson(Files.toString(file, StandardCharsets.UTF_8), STRING_MAP_TYPE)); - } - - private Map parseTranslationFile(URL file) throws IOException { - return filterTranslations(gson.fromJson(Resources.toString(file, StandardCharsets.UTF_8), STRING_MAP_TYPE)); + private Map parseTranslationFile(InputStream inputStream) { + return filterTranslations(gson.fromJson(new InputStreamReader(inputStream), STRING_MAP_TYPE)); } private Optional> loadTranslationFile(String filename) { Map baseTranslations; try { - baseTranslations = parseTranslationFile(ResourceLoader.getResourceRoot("lang/" + filename)); + baseTranslations = parseTranslationFile(ResourceLoader.getResourceRoot("lang/" + filename).openStream()); } catch (IOException e) { // Seem to be missing base. If the user has provided a file use that. baseTranslations = new HashMap<>(); @@ -102,7 +101,7 @@ public class TranslationManager { File localFile = worldEdit.getWorkingDirectoryFile("lang/" + filename); if (localFile.exists()) { try { - baseTranslations.putAll(parseTranslationFile(localFile)); + baseTranslations.putAll(parseTranslationFile(new FileInputStream(localFile))); } catch (IOException e) { // Failed to parse custom language file. Worth printing. e.printStackTrace(); diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index f8a005983..968b00ffc 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -37,7 +37,7 @@ "worldedit.drawsel.enabled.already": "Server CUI already enabled.", "worldedit.limit.too-high": "Your maximum allowable limit is {0}.", "worldedit.limit.set": "Block change limit set to {0}.", - "worldedit.limit.return-to-default": " (Use //limit to go back to the default.)", + "worldedit.limit.return-to-default": "(Use //limit to go back to the default.)", "worldedit.timeout.too-high": "Your maximum allowable timeout is {0}ms.", "worldedit.timeout.set": "Timeout time set to {0} ms.", "worldedit.timeout.return-to-default": " (Use //timeout to go back to the default.)", @@ -52,7 +52,7 @@ "worldedit.toggleplace.pos1": "Now placing at pos #1.", "worldedit.toggleplace.player": "Now placing at the block you stand in.", "worldedit.searchitem.too-short": "Enter a longer search string (len > 2).", - "worldedit.searchitem.b-and-i": "You cannot use both the 'b' and 'i' flags simultaneously.", + "worldedit.searchitem.either-b-or-i": "You cannot use both the 'b' and 'i' flags simultaneously.", "worldedit.searchitem.searching": "(Please wait... searching items.)", "worldedit.watchdog.no-hook": "This platform has no watchdog hook.", "worldedit.watchdog.active.already": "Watchdog hook already active.", @@ -323,5 +323,8 @@ "worldedit.help.command-not-found": "The command '{0}' could not be found.", "worldedit.help.no-subcommands": "'{0}' has no sub-commands. (Maybe '{1}' is for a parameter?)", - "worldedit.help.subcommand-not-found": "The sub-command '{0}' under '{1}' could not be found." + "worldedit.help.subcommand-not-found": "The sub-command '{0}' under '{1}' could not be found.", + + "worldedit.cli.stopping": "Stopping!", + "worldedit.cli.unknown-command": "Unknown command!" } \ No newline at end of file diff --git a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorServerPlayerEntity.java b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorServerPlayerEntity.java index a7e86af41..1e9b844b3 100644 --- a/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorServerPlayerEntity.java +++ b/worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/mixin/AccessorServerPlayerEntity.java @@ -26,6 +26,6 @@ import org.spongepowered.asm.mixin.gen.Accessor; @Mixin(ServerPlayerEntity.class) public interface AccessorServerPlayerEntity { - @Accessor("clientLanguage") + @Accessor String getClientLanguage(); } 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 822bb0954..fbad989c1 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 @@ -27,7 +27,6 @@ import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.Hand; import net.minecraft.world.World; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.gen.Accessor; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeCommandSender.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeCommandSender.java index fb3d31695..e9b8d62a6 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeCommandSender.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/SpongeCommandSender.java @@ -22,6 +22,7 @@ package com.sk89q.worldedit.sponge; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; +import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.internal.cui.CUIEvent; import com.sk89q.worldedit.session.SessionKey; @@ -144,7 +145,7 @@ public class SpongeCommandSender implements Actor { @Override public Locale getLocale() { - return Locale.US; + return WorldEdit.getInstance().getConfiguration().defaultLocale; } @Override diff --git a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java index 377633000..f93c21612 100644 --- a/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java +++ b/worldedit-sponge/src/main/java/com/sk89q/worldedit/sponge/config/ConfigurateConfiguration.java @@ -34,6 +34,7 @@ import org.slf4j.Logger; import java.io.IOException; import java.util.HashSet; +import java.util.Locale; public class ConfigurateConfiguration extends LocalConfiguration { @@ -131,5 +132,11 @@ public class ConfigurateConfiguration extends LocalConfiguration { shellSaveType = type.equals("") ? null : type; extendedYLimit = node.getNode("compat", "extended-y-limit").getBoolean(false); + defaultLocaleName = node.getNode("default-locale").getString(defaultLocaleName); + if (defaultLocaleName.equals("default")) { + defaultLocale = Locale.getDefault(); + } else { + defaultLocale = Locale.forLanguageTag(defaultLocaleName.replace('_', '-')); + } } } \ No newline at end of file