- Removal of additional command localization complexity

This commit is contained in:
Matthew Cech
2019-06-29 23:51:24 -07:00
parent 07613b3144
commit d054cf2036
2 changed files with 21 additions and 33 deletions
+19 -31
View File
@@ -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<String, String>(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;