- 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
+2 -2
View File
@@ -125,8 +125,8 @@ public abstract class BaseLocFile implements IConfigSection
} }
} }
// Returns the value. If the localized string is empty, // Returns the localized string if available.
// returns a the key instead which is the default phrase. // If the localized string is empty, returns a the key instead as the default phrase.
public String getKey(String input) public String getKey(String input)
{ {
if(localized == null) if(localized == null)
+18 -30
View File
@@ -36,35 +36,23 @@ public class CommandManager
if(pair == null || pair.Second == null) if(pair == null || pair.Second == null)
return; return;
String key = pair.Second; String[] keys = pair.Second.split(",");
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)
{
for(int i = 0; i < keys.length; ++i) 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! // Calls the command but on a whole new thread!
@@ -74,9 +62,9 @@ public class CommandManager
if(input == null || !input.isValid()) if(input == null || !input.isValid())
return false; return false;
// If we haven't already split a multisplit command (or even assessed that), // At this point, verify that the command is enabled. If we don't have any info
// then verify if we even need to register the commands at all. If it's // on if it's enabled or not, we assume it's enabled to prevent broken functionality due
// not enabled, don't register it. // to formatting or casing issues.
if(input.key != null && !commandEnabler.isEnabled(input.key)) if(input.key != null && !commandEnabler.isEnabled(input.key))
return false; return false;