Add /r for quick replying to private messages.

This commit is contained in:
cnaude 2015-06-20 15:10:00 -07:00
parent 6e04672421
commit 19aacbf847
6 changed files with 32 additions and 4 deletions

View File

@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
@ -141,7 +142,27 @@ public class CommandHandlers implements CommandExecutor {
return true;
}
} else if (commandLabel.equalsIgnoreCase("r")) {
plugin.logDebug("Command: r");
if (plugin.privateMsgReply.containsKey(sender.getName())) {
plugin.logDebug("Command: r2");
if (args.length >= 1) {
plugin.logDebug("Command: r3");
if (!sender.hasPermission("irc.smsg")) {
sender.sendMessage(plugin.noPermission);
return true;
}
plugin.logDebug("Command: r4");
ArrayList<String> list = new ArrayList<>();
list.add("smsg");
list.add(plugin.privateMsgReply.get(sender.getName()));
list.addAll(Arrays.asList(args));
plugin.logDebug("R: " + list);
commands.get("smsg").dispatch(sender, list.toArray(new String[list.size()]));
return true;
}
} else {
sender.sendMessage(ChatColor.RED + "No messages received.");
}
}
commands.get("help").dispatch(sender, args);
return true;

View File

@ -86,7 +86,8 @@ public class SMsg implements IRCCommandInterface {
sender.sendMessage(responseMsg);
}
plugin.logDebug("Tokenized message: " + targetMsg);
player.sendMessage(targetMsg);
player.sendMessage(targetMsg);
plugin.privateMsgReply.put(player.getName(), sender.getName());
return;
}

View File

@ -20,7 +20,6 @@ import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import com.cnaude.purpleirc.Utilities.CaseInsensitiveMap;
import java.util.ArrayList;
import java.util.Arrays;
import org.apache.commons.codec.binary.Base64;
import org.pircbotx.Channel;
import org.pircbotx.User;

View File

@ -2693,6 +2693,7 @@ public final class PurpleBot {
String template = plugin.getMsgTemplate(botNick, "", TemplateName.CROSS_CHAT);
String m = template.replace("%MESSAGE%", msg).replace("%SERVER%", user.getNick());
player.sendMessage(plugin.colorConverter.ircColorsToGame(m));
plugin.privateMsgReply.put(pName, from);
} else {
//no such player online
}

View File

@ -219,6 +219,7 @@ public class PurpleIRC extends JavaPlugin {
public static final String TOWNYTAG = "VG93bnlDaGF0Cg==";
public static final String LINK_CMD = "PurpleIRC-Link:";
public boolean overrideMsgCmd = false;
public CaseInsensitiveMap<String> privateMsgReply;
public PurpleIRC() {
this.MAINCONFIG = "MAIN-CONFIG";
@ -237,6 +238,7 @@ public class PurpleIRC extends JavaPlugin {
this.cacheFile = new File("plugins/PurpleIRC/displayName.cache");
this.uuidCacheFile = new File("plugins/PurpleIRC/uuid.cache");
this.reconnectSuppression = 0;
this.privateMsgReply = new CaseInsensitiveMap<>();
}
/**
@ -288,6 +290,7 @@ public class PurpleIRC extends JavaPlugin {
getCommand("irc").setTabCompleter(ircTabCompleter);
if (overrideMsgCmd) {
getCommand("msg").setExecutor(commandHandlers);
getCommand("r").setExecutor(commandHandlers);
}
regexGlobber = new RegexGlobber();
tokenizer = new ChatTokenizer(this);

View File

@ -27,8 +27,11 @@ commands:
description: Various irc commands
usage: /<command> help - List all irc commands available.
msg:
description: Shortcut for /irc smsg
description: Shortcut for /irc smsg.
usage: /<command> [player] message
r:
description: Shortut for replying to private messages.
usage: /<command> message
permissions:
'irc.reloadconfig':
description: Gives player access to the /irc reloadconfig.