|
|
|
@ -39,11 +39,6 @@ class CommandDispatcher
|
|
|
|
|
*/
|
|
|
|
|
private HashMap<String, String> shortList;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The command prefix used to call commands
|
|
|
|
|
*/
|
|
|
|
|
private String commandPrefix;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Thread pool used to invoke commands
|
|
|
|
|
*/
|
|
|
|
@ -58,12 +53,10 @@ class CommandDispatcher
|
|
|
|
|
rebuildCommandList();
|
|
|
|
|
threadPool = Executors.newCachedThreadPool(new BasicThreadFactory.Builder().namingPattern("CommandDispatcher-%d").build()); // TODO: threadPool.shutdown()
|
|
|
|
|
|
|
|
|
|
if(Configuration.exists("general", "commandPrefix") && !Configuration.getValue("general", "commandPrefix").isEmpty())
|
|
|
|
|
commandPrefix = Configuration.getValue("general", "commandPrefix");
|
|
|
|
|
else
|
|
|
|
|
if(!Configuration.exists("general", "commandPrefix") || Configuration.getValue("general", "commandPrefix").isEmpty())
|
|
|
|
|
{
|
|
|
|
|
logger.warning("Invalid command prefix detected, falling back to \"!\"");
|
|
|
|
|
commandPrefix = "!";
|
|
|
|
|
Configuration.setValue("general", "commandPrefix", "!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -84,7 +77,7 @@ class CommandDispatcher
|
|
|
|
|
public void onMessageReceivedEvent(MessageReceivedEvent event)
|
|
|
|
|
{
|
|
|
|
|
// Command matcher
|
|
|
|
|
Matcher m = Pattern.compile("^" + commandPrefix + "([:\\w]+)(?: (.*))?$").matcher(event.getMessage().getContent());
|
|
|
|
|
Matcher m = Pattern.compile("^" + Configuration.getValue("general", "commandPrefix") + "([:\\w]+)(?: (.*))?$").matcher(event.getMessage().getContent());
|
|
|
|
|
if(!m.matches()) return; // We don't need to go further if it's not even a command
|
|
|
|
|
String fullCommand = m.group(1).toLowerCase();
|
|
|
|
|
|
|
|
|
|