mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-25 03:55:27 +01:00
Add basic locale support.
This commit is contained in:
parent
4fc7519880
commit
0cd5df0a5e
@ -1,5 +1,6 @@
|
|||||||
package com.onarandombox.MultiverseCore.commands;
|
package com.onarandombox.MultiverseCore.commands;
|
||||||
|
|
||||||
|
import co.aikar.commands.CommandIssuer;
|
||||||
import co.aikar.commands.annotation.CommandAlias;
|
import co.aikar.commands.annotation.CommandAlias;
|
||||||
import co.aikar.commands.annotation.CommandCompletion;
|
import co.aikar.commands.annotation.CommandCompletion;
|
||||||
import co.aikar.commands.annotation.CommandPermission;
|
import co.aikar.commands.annotation.CommandPermission;
|
||||||
@ -9,6 +10,7 @@ import co.aikar.commands.annotation.Subcommand;
|
|||||||
import co.aikar.commands.annotation.Syntax;
|
import co.aikar.commands.annotation.Syntax;
|
||||||
import com.dumptruckman.minecraft.util.Logging;
|
import com.dumptruckman.minecraft.util.Logging;
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
|
import com.onarandombox.MultiverseCore.messaging.CoreMessageKeys;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -22,35 +24,35 @@ public class DebugCommand extends MultiverseCoreCommand {
|
|||||||
|
|
||||||
@Subcommand("debug")
|
@Subcommand("debug")
|
||||||
@CommandPermission("multiverse.core.debug")
|
@CommandPermission("multiverse.core.debug")
|
||||||
@Description("Show the current debug level.")
|
@Description("{@@mv-core.debug_info_description}")
|
||||||
public void onShowDebugCommand(@NotNull CommandSender sender) {
|
public void onShowDebugCommand(@NotNull CommandIssuer issuer) {
|
||||||
this.displayDebugMode(sender);
|
this.displayDebugMode(issuer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subcommand("debug")
|
@Subcommand("debug")
|
||||||
@CommandPermission("multiverse.core.debug")
|
@CommandPermission("multiverse.core.debug")
|
||||||
@Syntax("<level>")
|
@Syntax("<{@@mv-core.debug_change_syntax}>")
|
||||||
@CommandCompletion("@toggles|@range:3")
|
@CommandCompletion("@range:3")
|
||||||
@Description("Change debug level.")
|
@Description("{@@mv-core.debug_change_description}")
|
||||||
public void onChangeDebugCommand(@NotNull CommandSender sender,
|
public void onChangeDebugCommand(@NotNull CommandIssuer issuer,
|
||||||
|
|
||||||
@Conditions("debuglevel")
|
@Conditions("debuglevel")
|
||||||
@Syntax("<level>")
|
@Syntax("<{@@mv-core.debug_change_syntax}>")
|
||||||
@Description("Debug level to set to.")
|
@Description("{@@mv-core.debug_change_level_description}")
|
||||||
int level) {
|
int level) {
|
||||||
|
|
||||||
this.plugin.getMVConfig().setGlobalDebug(level);
|
this.plugin.getMVConfig().setGlobalDebug(level);
|
||||||
this.saveMVConfigs(sender);
|
this.saveMVConfigs(issuer);
|
||||||
this.displayDebugMode(sender);
|
this.displayDebugMode(issuer);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayDebugMode(@NotNull CommandSender sender) {
|
private void displayDebugMode(@NotNull CommandIssuer issuer) {
|
||||||
final int debugLevel = this.plugin.getMVConfig().getGlobalDebug();
|
final int debugLevel = this.plugin.getMVConfig().getGlobalDebug();
|
||||||
if (debugLevel == 0) {
|
if (debugLevel == 0) {
|
||||||
sender.sendMessage("Multiverse Debug mode is " + ChatColor.RED + "OFF");
|
issuer.sendInfo(CoreMessageKeys.DEBUG_INFO_OFF);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
sender.sendMessage("Multiverse Debug mode is at level " + ChatColor.GREEN + debugLevel);
|
issuer.sendInfo(CoreMessageKeys.DEBUG_INFO_ON, "{level}", String.valueOf(debugLevel));
|
||||||
Logging.fine("Multiverse Debug ENABLED");
|
Logging.fine("Multiverse Debug ENABLED.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package com.onarandombox.MultiverseCore.commands;
|
package com.onarandombox.MultiverseCore.commands;
|
||||||
|
|
||||||
|
import co.aikar.commands.CommandIssuer;
|
||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
import com.onarandombox.MultiverseCore.commandtools.MultiverseCommand;
|
||||||
import org.bukkit.ChatColor;
|
import com.onarandombox.MultiverseCore.messaging.CoreMessageKeys;
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generic multiverse core command with handy reference to the plugin instance.
|
* Generic multiverse core command with handy reference to the plugin instance.
|
||||||
@ -16,12 +16,11 @@ public abstract class MultiverseCoreCommand extends MultiverseCommand {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean saveMVConfigs(CommandSender sender) {
|
protected boolean saveMVConfigs(CommandIssuer issuer) {
|
||||||
if (this.plugin.saveMVConfigs()) {
|
if (this.plugin.saveMVConfigs()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
sender.sendMessage(ChatColor.RED + "An error occurred while trying to save Multiverse-Core config.yml. " +
|
issuer.sendError(CoreMessageKeys.CONFIG_SAVE_FAILED);
|
||||||
"You changes will be temporary!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,8 @@ import co.aikar.commands.PaperCommandManager;
|
|||||||
import com.onarandombox.MultiverseCore.MultiverseCore;
|
import com.onarandombox.MultiverseCore.MultiverseCore;
|
||||||
import com.onarandombox.MultiverseCore.commands.DebugCommand;
|
import com.onarandombox.MultiverseCore.commands.DebugCommand;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main class to manage permissions.
|
* Main class to manage permissions.
|
||||||
*/
|
*/
|
||||||
@ -20,6 +22,11 @@ public class MVCommandManager extends PaperCommandManager {
|
|||||||
super(plugin);
|
super(plugin);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
|
|
||||||
|
// Setup locale
|
||||||
|
this.addSupportedLanguage(Locale.ENGLISH);
|
||||||
|
this.locales.addMessageBundles("multiverse-core");
|
||||||
|
this.locales.loadLanguages();
|
||||||
|
|
||||||
// Register commands
|
// Register commands
|
||||||
this.registerCommand(new DebugCommand(plugin));
|
this.registerCommand(new DebugCommand(plugin));
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
7
src/main/resources/multiverse-core_en.properties
Normal file
7
src/main/resources/multiverse-core_en.properties
Normal 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.
|
Loading…
Reference in New Issue
Block a user