diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java index dfd76e6b..6ae4aaff 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/DebugCommand.java @@ -1,5 +1,6 @@ package com.onarandombox.MultiverseCore.commands; +import co.aikar.commands.CommandIssuer; import co.aikar.commands.annotation.CommandAlias; import co.aikar.commands.annotation.CommandCompletion; import co.aikar.commands.annotation.CommandPermission; @@ -9,6 +10,7 @@ import co.aikar.commands.annotation.Subcommand; import co.aikar.commands.annotation.Syntax; import com.dumptruckman.minecraft.util.Logging; import com.onarandombox.MultiverseCore.MultiverseCore; +import com.onarandombox.MultiverseCore.messaging.CoreMessageKeys; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; import org.jetbrains.annotations.NotNull; @@ -22,35 +24,35 @@ public class DebugCommand extends MultiverseCoreCommand { @Subcommand("debug") @CommandPermission("multiverse.core.debug") - @Description("Show the current debug level.") - public void onShowDebugCommand(@NotNull CommandSender sender) { - this.displayDebugMode(sender); + @Description("{@@mv-core.debug_info_description}") + public void onShowDebugCommand(@NotNull CommandIssuer issuer) { + this.displayDebugMode(issuer); } @Subcommand("debug") @CommandPermission("multiverse.core.debug") - @Syntax("") - @CommandCompletion("@toggles|@range:3") - @Description("Change debug level.") - public void onChangeDebugCommand(@NotNull CommandSender sender, + @Syntax("<{@@mv-core.debug_change_syntax}>") + @CommandCompletion("@range:3") + @Description("{@@mv-core.debug_change_description}") + public void onChangeDebugCommand(@NotNull CommandIssuer issuer, @Conditions("debuglevel") - @Syntax("") - @Description("Debug level to set to.") + @Syntax("<{@@mv-core.debug_change_syntax}>") + @Description("{@@mv-core.debug_change_level_description}") int level) { this.plugin.getMVConfig().setGlobalDebug(level); - this.saveMVConfigs(sender); - this.displayDebugMode(sender); + this.saveMVConfigs(issuer); + this.displayDebugMode(issuer); } - private void displayDebugMode(@NotNull CommandSender sender) { + private void displayDebugMode(@NotNull CommandIssuer issuer) { final int debugLevel = this.plugin.getMVConfig().getGlobalDebug(); if (debugLevel == 0) { - sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF"); + issuer.sendInfo(CoreMessageKeys.DEBUG_INFO_OFF); return; } - sender.sendMessage("Multiverse Debug mode is at level " + ChatColor.GREEN + debugLevel); - Logging.fine("Multiverse Debug ENABLED"); + issuer.sendInfo(CoreMessageKeys.DEBUG_INFO_ON, "{level}", String.valueOf(debugLevel)); + Logging.fine("Multiverse Debug ENABLED."); } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/MultiverseCoreCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/MultiverseCoreCommand.java index ebf7134d..22f15227 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/MultiverseCoreCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/MultiverseCoreCommand.java @@ -1,9 +1,9 @@ package com.onarandombox.MultiverseCore.commands; +import co.aikar.commands.CommandIssuer; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand; -import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; +import com.onarandombox.MultiverseCore.messaging.CoreMessageKeys; /** * Generic multiverse core command with handy reference to the plugin instance. @@ -16,12 +16,11 @@ public abstract class MultiverseCoreCommand extends MultiverseCommand { this.plugin = plugin; } - protected boolean saveMVConfigs(CommandSender sender) { + protected boolean saveMVConfigs(CommandIssuer issuer) { if (this.plugin.saveMVConfigs()) { return true; } - sender.sendMessage(ChatColor.RED + "An error occurred while trying to save Multiverse-Core config.yml. " + - "You changes will be temporary!"); + issuer.sendError(CoreMessageKeys.CONFIG_SAVE_FAILED); return false; } } diff --git a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java index b066dbf0..7d8549e9 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commandtools/MVCommandManager.java @@ -9,6 +9,8 @@ import co.aikar.commands.PaperCommandManager; import com.onarandombox.MultiverseCore.MultiverseCore; import com.onarandombox.MultiverseCore.commands.DebugCommand; +import java.util.Locale; + /** * Main class to manage permissions. */ @@ -20,6 +22,11 @@ public class MVCommandManager extends PaperCommandManager { super(plugin); this.plugin = plugin; + // Setup locale + this.addSupportedLanguage(Locale.ENGLISH); + this.locales.addMessageBundles("multiverse-core"); + this.locales.loadLanguages(); + // Register commands this.registerCommand(new DebugCommand(plugin)); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/messaging/CoreMessageKeys.java b/src/main/java/com/onarandombox/MultiverseCore/messaging/CoreMessageKeys.java new file mode 100644 index 00000000..7e4d92f2 --- /dev/null +++ b/src/main/java/com/onarandombox/MultiverseCore/messaging/CoreMessageKeys.java @@ -0,0 +1,20 @@ +package com.onarandombox.MultiverseCore.messaging; + +import co.aikar.locales.MessageKey; +import co.aikar.locales.MessageKeyProvider; + +import java.util.Locale; + +public enum CoreMessageKeys implements MessageKeyProvider { + + CONFIG_SAVE_FAILED, + DEBUG_INFO_OFF, + DEBUG_INFO_ON; + + private final MessageKey key = MessageKey.of("mv-core." + this.name().toLowerCase(Locale.ENGLISH)); + + @Override + public MessageKey getMessageKey() { + return this.key; + } +} diff --git a/src/main/resources/multiverse-core_en.properties b/src/main/resources/multiverse-core_en.properties new file mode 100644 index 00000000..8036f0b7 --- /dev/null +++ b/src/main/resources/multiverse-core_en.properties @@ -0,0 +1,7 @@ +mv-core.config_save_failed=§cUnable to save Multiverse-Core config.yml. Your changes will be temporary! +mv-core.debug_info_description=Show the current debug level. +mv-core.debug_info_off=§fMultiverse Debug mode is §cOFF§f. +mv-core.debug_info_on=§fMultiverse Debug mode is at §alevel {level}§f. +mv-core.debug_change_description=Change debug level. +mv-core.debug_change_syntax=level +mv-core.debug_change_level_description=Debug level to set to. \ No newline at end of file