Add new command-sent message template.

This commit is contained in:
cnaude 2016-01-06 22:57:44 -07:00
parent 8411d2178c
commit 1e814a3a30
6 changed files with 32 additions and 10 deletions

View File

@ -68,7 +68,7 @@ public class CommandQueueWatcher {
plugin.logDebug("Dispatching command as ConsoleSender: " + ircCommand.getGameCommand()); plugin.logDebug("Dispatching command as ConsoleSender: " + ircCommand.getGameCommand());
plugin.getServer().dispatchCommand(ircCommand.getIRCConsoleCommandSender(), ircCommand.getGameCommand()); plugin.getServer().dispatchCommand(ircCommand.getIRCConsoleCommandSender(), ircCommand.getGameCommand());
ircCommand.getIRCConsoleCommandSender().sendMessage("Command sent: " + ircCommand.getGameCommand()); ircCommand.getIRCConsoleCommandSender().sendMessage(plugin.tokenizer.ircCommandSentTokenizer(ircCommand.getGameCommand()));
} else { } else {
plugin.logDebug("Dispatching command as IRCCommandSender: " + ircCommand.getGameCommand()); plugin.logDebug("Dispatching command as IRCCommandSender: " + ircCommand.getGameCommand());
plugin.getServer().dispatchCommand(ircCommand.getIRCCommandSender(), ircCommand.getGameCommand()); plugin.getServer().dispatchCommand(ircCommand.getIRCCommandSender(), ircCommand.getGameCommand());

View File

@ -45,9 +45,11 @@ public class IRCCommandSender implements CommandSender {
*/ */
@Override @Override
public void sendMessage(String message) { public void sendMessage(String message) {
if (!message.isEmpty()) {
plugin.logDebug("sendMessage: " + message); plugin.logDebug("sendMessage: " + message);
addMessageToQueue(template.replace("%RESULT%", message)); addMessageToQueue(template.replace("%RESULT%", message));
} }
}
/** /**
* *
@ -56,10 +58,12 @@ public class IRCCommandSender implements CommandSender {
@Override @Override
public void sendMessage(String[] messages) { public void sendMessage(String[] messages) {
for (String message : messages) { for (String message : messages) {
if (!message.isEmpty()) {
plugin.logDebug("sendMessage[]: " + message); plugin.logDebug("sendMessage[]: " + message);
addMessageToQueue(template.replace("%RESULT%", message)); addMessageToQueue(template.replace("%RESULT%", message));
} }
} }
}
private void addMessageToQueue(String message) { private void addMessageToQueue(String message) {
ircBot.messageQueue.add(new IRCMessage(target, ircBot.messageQueue.add(new IRCMessage(target,

View File

@ -46,9 +46,11 @@ public class IRCConsoleCommandSender implements ConsoleCommandSender {
*/ */
@Override @Override
public void sendMessage(String message) { public void sendMessage(String message) {
if (!message.isEmpty()) {
plugin.logDebug("sendMessage: " + message); plugin.logDebug("sendMessage: " + message);
addMessageToQueue(message); addMessageToQueue(message);
} }
}
/** /**
* *
@ -57,10 +59,12 @@ public class IRCConsoleCommandSender implements ConsoleCommandSender {
@Override @Override
public void sendMessage(String[] messages) { public void sendMessage(String[] messages) {
for (String message : messages) { for (String message : messages) {
if (!message.isEmpty()) {
plugin.logDebug("sendMessage[]: " + message); plugin.logDebug("sendMessage[]: " + message);
addMessageToQueue(message); addMessageToQueue(message);
} }
} }
}
private void addMessageToQueue(String message) { private void addMessageToQueue(String message) {
ircBot.messageQueue.add(new IRCMessage(target, ircBot.messageQueue.add(new IRCMessage(target,

View File

@ -163,4 +163,6 @@ public class TemplateName {
public final static String LOG_TAILER = "log-tailer"; public final static String LOG_TAILER = "log-tailer";
public final static String COMMAND_SENT = "command-sent";
} }

View File

@ -993,6 +993,16 @@ public class ChatTokenizer {
); );
} }
/**
*
* @param command
* @return
*/
public String ircCommandSentTokenizer(String command) {
return plugin.getMessageTemplate(TemplateName.COMMAND_SENT)
.replace("%COMMAND%", command);
}
/** /**
* *
* @param sender * @param sender

View File

@ -96,6 +96,8 @@ message-format:
console-chat: '[&dServer&r] %MESSAGE%' console-chat: '[&dServer&r] %MESSAGE%'
# Cross server chatting via linked bots # Cross server chatting via linked bots
cross-chat: '[&4%SERVER%&r] %MESSAGE%' cross-chat: '[&4%SERVER%&r] %MESSAGE%'
# Command sent notification. Blank this to disable this message.
command-sent: 'Command sent: %COMMAND%'
game-achievement: '[&2%WORLD%&r] %NAME% has just earned the achievement [%MESSAGE%]' game-achievement: '[&2%WORLD%&r] %NAME% has just earned the achievement [%MESSAGE%]'
game-mode: '[&2%WORLD%&r] %NAME% has changed game mode: [%MESSAGE%]' game-mode: '[&2%WORLD%&r] %NAME% has changed game mode: [%MESSAGE%]'
game-action: '[&2%WORLD%&r]***%NAME% %MESSAGE%' game-action: '[&2%WORLD%&r]***%NAME% %MESSAGE%'