mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2025-02-03 05:01:25 +01:00
Add /r for quick replying to private messages.
This commit is contained in:
parent
6e04672421
commit
19aacbf847
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user