From d054cf20363873b2ed3c42707cd25060127885d5 Mon Sep 17 00:00:00 2001 From: Matthew Cech Date: Sat, 29 Jun 2019 23:51:24 -0700 Subject: [PATCH] - Removal of additional command localization complexity --- src/core/BaseLocFile.java | 4 +-- src/core/CommandManager.java | 50 ++++++++++++++---------------------- 2 files changed, 21 insertions(+), 33 deletions(-) diff --git a/src/core/BaseLocFile.java b/src/core/BaseLocFile.java index 6b9982f..2d6b396 100644 --- a/src/core/BaseLocFile.java +++ b/src/core/BaseLocFile.java @@ -125,8 +125,8 @@ public abstract class BaseLocFile implements IConfigSection } } - // Returns the value. If the localized string is empty, - // returns a the key instead which is the default phrase. + // Returns the localized string if available. + // If the localized string is empty, returns a the key instead as the default phrase. public String getKey(String input) { if(localized == null) diff --git a/src/core/CommandManager.java b/src/core/CommandManager.java index 2c72484..0db4448 100644 --- a/src/core/CommandManager.java +++ b/src/core/CommandManager.java @@ -36,35 +36,23 @@ public class CommandManager if(pair == null || pair.Second == null) return; - String key = pair.Second; - - if(key.contains(",")) - { - - String[] keys = key.split(","); - register(keys, command); - return; - } - - key = key.toLowerCase(); - command.registeredNames.add(key); - - Command old = commands.put(key, command); - - if(old != null) - { - GlobalLog.warn(LogFilter.Core, "Writing over a command with the key " + key); - return; - } - - GlobalLog.log(LogFilter.Core, "Command registered under key " + key); - } - - // Registers a command under multiple names! - public void register(String[] keys, Command command) - { + String[] keys = pair.Second.split(","); + for(int i = 0; i < keys.length; ++i) - register(new Pair(null, keys[i].trim()), command); + { + String key = keys[i].trim().toLowerCase(); + + command.registeredNames.add(key); + Command old = commands.put(key, command); + + if(old != null) + { + GlobalLog.warn(LogFilter.Core, "Writing over a command with the key " + key); + return; + } + + GlobalLog.log(LogFilter.Core, "Command registered under key " + key); + } } // Calls the command but on a whole new thread! @@ -74,9 +62,9 @@ public class CommandManager if(input == null || !input.isValid()) return false; - // If we haven't already split a multisplit command (or even assessed that), - // then verify if we even need to register the commands at all. If it's - // not enabled, don't register it. + // At this point, verify that the command is enabled. If we don't have any info + // on if it's enabled or not, we assume it's enabled to prevent broken functionality due + // to formatting or casing issues. if(input.key != null && !commandEnabler.isEnabled(input.key)) return false;