mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-17 07:35:38 +01:00
Fix game_command_usage.
Add args_required option for commands.
This commit is contained in:
parent
32ea50f9da
commit
efe102ddaa
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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"));
|
||||
|
Loading…
Reference in New Issue
Block a user