Fix game_command_usage.

Add args_required option for commands.
This commit is contained in:
cnaude 2016-11-26 18:51:29 -07:00
parent 32ea50f9da
commit efe102ddaa
2 changed files with 21 additions and 18 deletions

View File

@ -127,6 +127,7 @@ public class IRCMessageHandler {
}
}
String gcUsage = (String) ircBot.commandMap.get(channelName).get(command).get("game_command_usage");
boolean argsRequired = Boolean.parseBoolean(ircBot.commandMap.get(channelName).get(command).get("args_required"));
List<String> extraCommands = ircBot.extraCommandMap.get(channelName).get(command);
List<String> gameCommands = new ArrayList<>();
List<String> userMasks = ircBot.commandUsermasksMap.get(channelName).get(command);
@ -228,6 +229,14 @@ public class IRCMessageHandler {
commandArgs = "";
}
if (commandArgs.isEmpty() && argsRequired) {
plugin.logDebug("GM BAIL: \"" + gameCommand.trim() + "\"");
String usageResponse = plugin.colorConverter.gameColorsToIrc(
ChatColor.translateAlternateColorCodes('&', gcUsage));
sendMessage(ircBot, target, usageResponse, responseType);
break gc_loop;
}
if (gameCommand.contains("%ARGS%")) {
gameCommand = gameCommand.replace("%ARGS%", commandArgs);
}
@ -254,25 +263,17 @@ public class IRCMessageHandler {
}
}
if (gameCommand.matches(".*%ARG\\d+%.*")
|| gameCommand.matches(".*%ARG(\\d+)\\+%.*")
|| gameCommand.contains("%ARGS%")) {
plugin.logDebug("GM BAIL: \"" + gameCommand.trim() + "\"");
ircBot.asyncIRCMessage(target, plugin.colorConverter.gameColorsToIrc(
ChatColor.translateAlternateColorCodes('&', gcUsage)));
break gc_loop;
} else {
plugin.logDebug("GM: \"" + gameCommand.trim() + "\"");
try {
plugin.commandQueue.add(new IRCCommand(
new IRCCommandSender(ircBot, target, plugin, responseType, senderName, outputTemplate),
new IRCConsoleCommandSender(ircBot, target, plugin, responseType, senderName),
gameCommand.trim()
));
} catch (Exception ex) {
plugin.logError(ex.getMessage());
}
plugin.logDebug("GM: \"" + gameCommand.trim() + "\"");
try {
plugin.commandQueue.add(new IRCCommand(
new IRCCommandSender(ircBot, target, plugin, responseType, senderName, outputTemplate),
new IRCConsoleCommandSender(ircBot, target, plugin, responseType, senderName),
gameCommand.trim()
));
} catch (Exception ex) {
plugin.logError(ex.getMessage());
}
break;
}
}

View File

@ -1186,9 +1186,11 @@ public final class PurpleBot {
optionPair.put("modes", config.getString(commandKey + "modes", "*"));
optionPair.put("private", config.getString(commandKey + "private", "false"));
optionPair.put("ctcp", config.getString(commandKey + "ctcp", "false"));
optionPair.put("notice", config.getString(commandKey + "notice", "false"));
optionPair.put("game_command", config.getString(commandKey + "game_command", ""));
optionPair.put("cool_down", config.getString(commandKey + "cool_down", "0"));
optionPair.put("game_command_usage", config.getString(commandKey + "game_command_usage", ""));
optionPair.put("args_required", config.getString(commandKey + "args_required", "false"));
optionPair.put("sender", config.getString(commandKey + "sender", "CONSOLE"));
optionPair.put("private_listen", config.getString(commandKey + "private_listen", "true"));
optionPair.put("channel_listen", config.getString(commandKey + "channel_listen", "true"));