mirror of
https://github.com/aikar/commands.git
synced 2026-05-31 14:21:56 +00:00
autoload message bundles based on plugin name
This commit is contained in:
@@ -65,7 +65,8 @@ public class BukkitCommandManager extends CommandManager {
|
||||
@SuppressWarnings("JavaReflectionMemberAccess")
|
||||
public BukkitCommandManager(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.locales.addMessageBundle("acf-minecraft", Locale.ENGLISH);
|
||||
String pluginName = "acf-" + plugin.getDescription().getName();
|
||||
this.locales.addMessageBundles("acf-minecraft", pluginName, pluginName.toLowerCase());
|
||||
this.timingManager = TimingManager.of(plugin);
|
||||
this.commandTiming = this.timingManager.of("Commands");
|
||||
CommandMap commandMap = null;
|
||||
|
||||
@@ -41,14 +41,14 @@ import java.util.logging.Logger;
|
||||
public class BungeeCommandManager extends CommandManager {
|
||||
|
||||
protected final Plugin plugin;
|
||||
protected Map<String, Command> knownCommands = new HashMap<>();
|
||||
protected Map<String, BungeeRootCommand> registeredCommands = new HashMap<>();
|
||||
protected BungeeCommandContexts contexts;
|
||||
protected BungeeCommandCompletions completions;
|
||||
|
||||
public BungeeCommandManager(Plugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.locales.addMessageBundle("acf-minecraft", Locale.ENGLISH);
|
||||
String pluginName = "acf-" + plugin.getDescription().getName();
|
||||
this.locales.addMessageBundles("acf-minecraft", pluginName, pluginName.toLowerCase());
|
||||
this.formatters.put(MessageType.ERROR, new BungeeMessageFormatter(ChatColor.RED, ChatColor.YELLOW, ChatColor.RED));
|
||||
this.formatters.put(MessageType.SYNTAX, new BungeeMessageFormatter(ChatColor.YELLOW, ChatColor.GREEN, ChatColor.WHITE));
|
||||
this.formatters.put(MessageType.INFO, new BungeeMessageFormatter(ChatColor.BLUE, ChatColor.DARK_GREEN, ChatColor.GREEN));
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.lang.reflect.Parameter;
|
||||
import java.util.*;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
abstract class CommandManager {
|
||||
public abstract class CommandManager {
|
||||
|
||||
static ThreadLocal<Stack<CommandManager>> currentCommandManager = ThreadLocal.withInitial(Stack::new);
|
||||
static ThreadLocal<Stack<CommandIssuer>> currentCommandIssuer = ThreadLocal.withInitial(Stack::new);
|
||||
|
||||
@@ -40,13 +40,18 @@ public class Locales {
|
||||
Locales(CommandManager manager) {
|
||||
this.manager = manager;
|
||||
this.localeManager = LocaleManager.create(manager::getIssuerLocale);
|
||||
this.localeManager.addMessageBundle("acf-core", Locale.ENGLISH);
|
||||
this.localeManager.addMessageBundles("acf-core");
|
||||
}
|
||||
|
||||
public Locale getDefaultLocale() {
|
||||
return this.localeManager.getDefaultLocale();
|
||||
}
|
||||
|
||||
|
||||
public void addMessageBundles(String... bundleNames) {
|
||||
this.localeManager.addMessageBundles(bundleNames);
|
||||
}
|
||||
|
||||
public void addMessageBundle(String bundleName, Locale locale) {
|
||||
this.localeManager.addMessageBundle(bundleName, locale);
|
||||
}
|
||||
@@ -68,5 +73,4 @@ public class Locales {
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Parameter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
@@ -50,7 +49,8 @@ public class SpongeCommandManager extends CommandManager {
|
||||
|
||||
public SpongeCommandManager(PluginContainer plugin) {
|
||||
this.plugin = plugin;
|
||||
this.locales.addMessageBundle("acf-minecraft", Locale.ENGLISH);
|
||||
String pluginName = "acf-" + plugin.getName();
|
||||
this.locales.addMessageBundles("acf-minecraft", pluginName, pluginName.toLowerCase());
|
||||
this.commandTiming = Timings.of(plugin, "Commands");
|
||||
|
||||
this.formatters.put(MessageType.ERROR, new SpongeMessageFormatter(TextColors.RED, TextColors.YELLOW, TextColors.RED));
|
||||
|
||||
Reference in New Issue
Block a user