feat: Implement basic localisation

This commit is contained in:
Ben Woo 2023-02-02 17:06:36 +08:00
parent 3fb99bc156
commit a034eaa555
3 changed files with 38 additions and 3 deletions

View File

@ -5,9 +5,12 @@ import co.aikar.commands.annotation.CommandAlias;
import co.aikar.commands.annotation.CommandCompletion;
import co.aikar.commands.annotation.CommandPermission;
import co.aikar.commands.annotation.Conditions;
import co.aikar.commands.annotation.Description;
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.locale.MVCorei18n;
import org.jetbrains.annotations.NotNull;
@CommandAlias("mv")
@ -19,6 +22,7 @@ public class DebugCommand extends MultiverseCommand {
@Subcommand("debug")
@CommandPermission("multiverse.core.debug")
@Description("{@@mv-core.debug_info_description}")
public void onShowDebugCommand(@NotNull CommandIssuer issuer) {
this.displayDebugMode(issuer);
}
@ -26,9 +30,15 @@ public class DebugCommand extends MultiverseCommand {
@Subcommand("debug")
@CommandPermission("multiverse.core.debug")
@Syntax("<{@@mv-core.debug_change_syntax}>")
@CommandCompletion("@range:3")
@Description("{@@mv-core.debug_change_description}")
public void onChangeDebugCommand(@NotNull CommandIssuer issuer,
@Conditions("debuglevel") int level) {
@Conditions("debuglevel")
@Syntax("<{@@mv-core.debug_change_syntax}>")
@Description("{@@mv-core.debug_change_level_description}")
int level) {
this.plugin.getMVConfig().setGlobalDebug(level);
this.plugin.saveMVConfigs();
@ -38,10 +48,10 @@ public class DebugCommand extends MultiverseCommand {
private void displayDebugMode(@NotNull CommandIssuer issuer) {
final int debugLevel = this.plugin.getMVConfig().getGlobalDebug();
if (debugLevel == 0) {
issuer.sendMessage("§fMultiverse Debug mode is §cOFF§f.");
issuer.sendInfo(MVCorei18n.DEBUG_INFO_OFF);
return;
}
issuer.sendMessage("§fMultiverse Debug mode is at §alevel {level}§f.");
issuer.sendInfo(MVCorei18n.DEBUG_INFO_ON, "{level}", String.valueOf(debugLevel));
Logging.fine("Multiverse Debug ENABLED.");
}
}

View File

@ -0,0 +1,18 @@
package com.onarandombox.MultiverseCore.locale;
import co.aikar.locales.MessageKey;
import co.aikar.locales.MessageKeyProvider;
public enum MVCorei18n implements MessageKeyProvider {
CONFIG_SAVE_FAILED,
DEBUG_INFO_OFF,
DEBUG_INFO_ON;
private final MessageKey key = MessageKey.of("mv-core." + this.name().toLowerCase());
@Override
public MessageKey getMessageKey() {
return this.key;
}
}

View File

@ -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.