mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-10-02 08:27:33 +02:00
Improve PMs UX: reply command
Add NTheEndAgain hooks
This commit is contained in:
parent
ecd89e7e25
commit
7206d02d3a
@ -75,6 +75,7 @@ public class CommandHandlers implements CommandExecutor {
|
||||
commands.put("nick", new Nick(plugin));
|
||||
commands.put("notice", new Notice(plugin));
|
||||
commands.put("op", new Op(plugin));
|
||||
commands.put("r", new R(plugin));
|
||||
commands.put("reload", new Reload(plugin));
|
||||
commands.put("reloadbot", new ReloadBot(plugin));
|
||||
commands.put("reloadbotconfig", new ReloadBotConfig(plugin));
|
||||
|
102
src/main/java/com/cnaude/purpleirc/Commands/R.java
Normal file
102
src/main/java/com/cnaude/purpleirc/Commands/R.java
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
* Copyright (C) 2014 cnaude
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.cnaude.purpleirc.Commands;
|
||||
|
||||
import com.cnaude.purpleirc.PurpleBot;
|
||||
import com.cnaude.purpleirc.PurpleIRC;
|
||||
import com.cnaude.purpleirc.TemplateName;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Chris Naude
|
||||
*/
|
||||
public class R implements IRCCommandInterface {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
private final String usage = "([message])";
|
||||
private final String desc = "Reply to a private message from an IRC user.";
|
||||
private final String name = "r";
|
||||
private final String fullUsage = ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/irc " + name + " " + usage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin the PurpleIRC plugin
|
||||
*/
|
||||
public R(PurpleIRC plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sender
|
||||
* @param args
|
||||
*/
|
||||
@Override
|
||||
public void dispatch(CommandSender sender, String[] args) {
|
||||
if (args.length == 1) {
|
||||
for (PurpleBot ircBot : plugin.ircBots.values()) {
|
||||
if (ircBot.ircPrivateMsgMap.containsKey(sender.getName())) {
|
||||
sender.sendMessage("Most recent private is message is from " + ircBot.ircPrivateMsgMap.get(sender.getName()));
|
||||
}
|
||||
}
|
||||
} else if (args.length >= 2) {
|
||||
plugin.logDebug("Dispatching r command...");
|
||||
for (PurpleBot ircBot : plugin.ircBots.values()) {
|
||||
String nick = "";
|
||||
String msg = "";
|
||||
if (ircBot.ircPrivateMsgMap.containsKey(sender.getName())) {
|
||||
nick = ircBot.ircPrivateMsgMap.get(sender.getName());
|
||||
}
|
||||
if (nick.isEmpty()) {
|
||||
sender.sendMessage(ChatColor.WHITE + "Please use " + ChatColor.GOLD
|
||||
+ "/irc msg" + ChatColor.WHITE + " first.");
|
||||
continue;
|
||||
}
|
||||
final String template = plugin.getMsgTemplate(ircBot.botNick, "", TemplateName.GAME_PCHAT_RESPONSE);
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
msg = msg + " " + args[i];
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
ircBot.msgPlayer((Player) sender, nick, msg.substring(1));
|
||||
} else {
|
||||
ircBot.consoleMsgPlayer(nick, msg.substring(1));
|
||||
}
|
||||
if (!template.isEmpty()) {
|
||||
sender.sendMessage(plugin.tokenizer.msgChatResponseTokenizer(sender, nick, msg.substring(1), template));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String desc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String usage() {
|
||||
return usage;
|
||||
}
|
||||
}
|
@ -171,6 +171,9 @@ public class IRCMessageHandler {
|
||||
case "@msg":
|
||||
ircBot.playerChat(user, channel, target, commandArgs);
|
||||
break;
|
||||
case "@r":
|
||||
ircBot.playerReplyChat(user, channel, target, commandArgs);
|
||||
break;
|
||||
case "@clearqueue":
|
||||
sendMessage(ircBot, target, plugin.commandQueue.clearQueue(), ctcpResponse);
|
||||
sendMessage(ircBot, target, ircBot.messageQueue.clearQueue(), ctcpResponse);
|
||||
|
@ -194,6 +194,10 @@ public final class PurpleBot {
|
||||
private String tailerFile;
|
||||
private String tailerRecipient;
|
||||
private boolean tailerCtcp;
|
||||
/**
|
||||
* Map of player names to IRC nicks.
|
||||
*/
|
||||
public CaseInsensitiveMap<String> ircPrivateMsgMap;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -257,6 +261,7 @@ public final class PurpleBot {
|
||||
this.linkRequests = new CaseInsensitiveMap<>();
|
||||
this.remotePlayers = new CaseInsensitiveMap<>();
|
||||
this.remoteServerInfo = new CaseInsensitiveMap<>();
|
||||
this.ircPrivateMsgMap = new CaseInsensitiveMap<>();
|
||||
config = new YamlConfiguration();
|
||||
goodBot = loadConfig();
|
||||
if (goodBot) {
|
||||
@ -2821,9 +2826,31 @@ public final class PurpleBot {
|
||||
asyncIRCMessage(target, "No message specified.");
|
||||
}
|
||||
}
|
||||
|
||||
// Send chat messages from IRC to player
|
||||
|
||||
/**
|
||||
* Send chat messages from IRC to player.
|
||||
*
|
||||
* @param user
|
||||
* @param channel
|
||||
* @param target
|
||||
* @param message
|
||||
*/
|
||||
public void playerReplyChat(User user, org.pircbotx.Channel channel, String target, String message) {
|
||||
if (message == null) {
|
||||
plugin.logDebug("H: NULL MESSAGE");
|
||||
asyncIRCMessage(target, "No message specified!");
|
||||
return;
|
||||
}
|
||||
for (String name : ircPrivateMsgMap.keySet()) {
|
||||
if (ircPrivateMsgMap.get(name).equals(target)) {
|
||||
playerChat(user, channel, target, name + " " + message);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send chat messages from IRC to player.
|
||||
*
|
||||
* @param user
|
||||
* @param channel
|
||||
@ -2858,6 +2885,7 @@ public final class PurpleBot {
|
||||
}
|
||||
plugin.logDebug("Tokenized message: " + t);
|
||||
player.sendMessage(t);
|
||||
ircPrivateMsgMap.put(pName, user.getNick());
|
||||
} else {
|
||||
asyncIRCMessage(target, "Player is offline: " + pName);
|
||||
}
|
||||
@ -3218,6 +3246,7 @@ public final class PurpleBot {
|
||||
String msg = plugin.tokenizer.gameChatToIRCTokenizer(sender,
|
||||
plugin.getMsgTemplate(botNick, "", TemplateName.GAME_PCHAT), message);
|
||||
asyncIRCMessage(nick, msg);
|
||||
ircPrivateMsgMap.put(sender.getName(), nick);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -289,6 +289,7 @@ channels:
|
||||
# @ochat - send message to game (overrides irc-chat)
|
||||
# @motd - display minecraft server motd
|
||||
# @msg - send private message to player
|
||||
# @r - quickly reply to private message
|
||||
# @query - query remote minecraft server
|
||||
# @rtsmb - Send ReportRTS broadcast message to mods
|
||||
# @a - Send message to AdminPrivateChat
|
||||
|
@ -84,6 +84,9 @@ permissions:
|
||||
'irc.msg':
|
||||
description: Gives player access to the /irc msg command.
|
||||
default: op
|
||||
'irc.r':
|
||||
description: Gives player access to the /irc r command.
|
||||
default: op
|
||||
'irc.sendraw':
|
||||
description: Gives player access to the /irc sendraw command.
|
||||
default: op
|
||||
|
Loading…
Reference in New Issue
Block a user