diff --git a/bukkit/src/main/java/revxrsal/commands/bukkit/core/BukkitActor.java b/bukkit/src/main/java/revxrsal/commands/bukkit/core/BukkitActor.java index 6b58f61a..9a6b8201 100644 --- a/bukkit/src/main/java/revxrsal/commands/bukkit/core/BukkitActor.java +++ b/bukkit/src/main/java/revxrsal/commands/bukkit/core/BukkitActor.java @@ -9,8 +9,10 @@ import revxrsal.commands.bukkit.BukkitCommandActor; import revxrsal.commands.bukkit.exception.SenderNotConsoleException; import revxrsal.commands.bukkit.exception.SenderNotPlayerException; +import revxrsal.commands.locales.Locales; import java.nio.charset.StandardCharsets; +import java.util.Locale; import java.util.UUID; import static revxrsal.commands.util.Preconditions.notNull; @@ -82,4 +84,12 @@ else if (isConsole()) @Override public CommandHandler getCommandHandler() { return handler; } + + @Override public @NotNull Locale getLocale() { + if (isPlayer()) { + Locale locale = Locales.get(requirePlayer().getLocale()); + return locale == null ? BukkitCommandActor.super.getLocale() : locale; + } + return BukkitCommandActor.super.getLocale(); + } } diff --git a/bungee/src/main/java/revxrsal/commands/bungee/core/BungeeActor.java b/bungee/src/main/java/revxrsal/commands/bungee/core/BungeeActor.java index 0ec5c14a..31ecf04a 100644 --- a/bungee/src/main/java/revxrsal/commands/bungee/core/BungeeActor.java +++ b/bungee/src/main/java/revxrsal/commands/bungee/core/BungeeActor.java @@ -9,6 +9,7 @@ import revxrsal.commands.bungee.BungeeCommandActor; import revxrsal.commands.bungee.exception.SenderNotPlayerException; +import java.util.Locale; import java.util.UUID; import static revxrsal.commands.util.Strings.colorize; @@ -62,4 +63,10 @@ public BungeeActor(CommandSender sender, CommandHandler handler) { @Override public CommandHandler getCommandHandler() { return handler; } + + @Override public @NotNull Locale getLocale() { + if (isPlayer()) + return requirePlayer().getLocale(); + return BungeeCommandActor.super.getLocale(); + } } diff --git a/sponge/src/main/java/revxrsal/commands/sponge/core/SpongeActor.java b/sponge/src/main/java/revxrsal/commands/sponge/core/SpongeActor.java index bf030ac9..9318d44c 100644 --- a/sponge/src/main/java/revxrsal/commands/sponge/core/SpongeActor.java +++ b/sponge/src/main/java/revxrsal/commands/sponge/core/SpongeActor.java @@ -11,6 +11,7 @@ import revxrsal.commands.sponge.exception.SenderNotConsoleException; import revxrsal.commands.sponge.exception.SenderNotPlayerException; +import java.util.Locale; import java.util.UUID; import static revxrsal.commands.util.Strings.colorize; @@ -75,6 +76,12 @@ public SpongeActor(CommandSource source, CommandHandler handler) { return (ConsoleSource) source; } + @Override public @NotNull Locale getLocale() { + if (isPlayer()) + return requirePlayer().getLocale(); + return SpongeCommandActor.super.getLocale(); + } + @Override public void reply(@NotNull Text message) { source.sendMessage(message); } diff --git a/velocity/src/main/java/revxrsal/commands/velocity/core/VelocityActor.java b/velocity/src/main/java/revxrsal/commands/velocity/core/VelocityActor.java index 2d839761..0574febc 100644 --- a/velocity/src/main/java/revxrsal/commands/velocity/core/VelocityActor.java +++ b/velocity/src/main/java/revxrsal/commands/velocity/core/VelocityActor.java @@ -13,6 +13,7 @@ import revxrsal.commands.velocity.exception.SenderNotConsoleException; import revxrsal.commands.velocity.exception.SenderNotPlayerException; +import java.util.Locale; import java.util.UUID; import static revxrsal.commands.util.Preconditions.notNull; @@ -61,11 +62,16 @@ public VelocityActor(CommandSource source, ProxyServer server, CommandHandler ha source.sendMessage(component); } - @Override public void reply(@NotNull ComponentLike component) { source.sendMessage(component); } + @Override public @NotNull Locale getLocale() { + if (isPlayer()) + return requirePlayer().getPlayerSettings().getLocale(); + return VelocityCommandActor.super.getLocale(); + } + @Override public @NotNull ProxyServer getServer() { return server; }