mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-09-30 15:37:29 +02:00
Build with MC 1.11
This commit is contained in:
parent
83d4e4d68e
commit
d3842b1e81
10
pom.xml
10
pom.xml
@ -6,7 +6,7 @@
|
|||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<!-- Bukkit API Version, change if out dated -->
|
<!-- Bukkit API Version, change if out dated -->
|
||||||
<bukkit.version>1.10.2</bukkit.version>
|
<bukkit.version>1.11</bukkit.version>
|
||||||
<build.number>SNAPSHOT</build.number>
|
<build.number>SNAPSHOT</build.number>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@ -141,6 +141,14 @@
|
|||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bukkit</groupId>
|
||||||
|
<artifactId>spigot-111</artifactId>
|
||||||
|
<version>1.11</version>
|
||||||
|
<type>jar</type>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!-- PircBotX -->
|
<!-- PircBotX -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.cnaude.pircbotx</groupId>
|
<groupId>com.cnaude.pircbotx</groupId>
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.cnaude.purpleirc;
|
package com.cnaude.purpleirc;
|
||||||
|
|
||||||
|
import com.cnaude.purpleirc.IRCMessage.Type;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
@ -35,7 +36,7 @@ public class IRCCommandSender implements CommandSender {
|
|||||||
private final PurpleBot ircBot;
|
private final PurpleBot ircBot;
|
||||||
private final String target;
|
private final String target;
|
||||||
private final PurpleIRC plugin;
|
private final PurpleIRC plugin;
|
||||||
private final boolean ctcpResponse;
|
private final Type responseType;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String template;
|
private final String template;
|
||||||
|
|
||||||
@ -67,7 +68,7 @@ public class IRCCommandSender implements CommandSender {
|
|||||||
|
|
||||||
private void addMessageToQueue(String message) {
|
private void addMessageToQueue(String message) {
|
||||||
ircBot.messageQueue.add(new IRCMessage(target,
|
ircBot.messageQueue.add(new IRCMessage(target,
|
||||||
plugin.colorConverter.gameColorsToIrc(message), ctcpResponse));
|
plugin.colorConverter.gameColorsToIrc(message), responseType));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -75,16 +76,16 @@ public class IRCCommandSender implements CommandSender {
|
|||||||
* @param ircBot
|
* @param ircBot
|
||||||
* @param target
|
* @param target
|
||||||
* @param plugin the PurpleIRC plugin
|
* @param plugin the PurpleIRC plugin
|
||||||
* @param ctcpResponse
|
* @param responseType
|
||||||
* @param name
|
* @param name
|
||||||
* @param template
|
* @param template
|
||||||
*/
|
*/
|
||||||
public IRCCommandSender(PurpleBot ircBot, String target, PurpleIRC plugin, boolean ctcpResponse, String name, String template) {
|
public IRCCommandSender(PurpleBot ircBot, String target, PurpleIRC plugin, Type responseType, String name, String template) {
|
||||||
super();
|
super();
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.ircBot = ircBot;
|
this.ircBot = ircBot;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.ctcpResponse = ctcpResponse;
|
this.responseType = responseType;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.template = template;
|
this.template = template;
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.cnaude.purpleirc;
|
package com.cnaude.purpleirc;
|
||||||
|
|
||||||
|
import com.cnaude.purpleirc.IRCMessage.Type;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
@ -37,7 +38,7 @@ public class IRCConsoleCommandSender implements ConsoleCommandSender {
|
|||||||
private final PurpleBot ircBot;
|
private final PurpleBot ircBot;
|
||||||
private final String target;
|
private final String target;
|
||||||
private final PurpleIRC plugin;
|
private final PurpleIRC plugin;
|
||||||
private final boolean ctcpResponse;
|
private final Type type;
|
||||||
private final String name;
|
private final String name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -68,7 +69,7 @@ public class IRCConsoleCommandSender implements ConsoleCommandSender {
|
|||||||
|
|
||||||
private void addMessageToQueue(String message) {
|
private void addMessageToQueue(String message) {
|
||||||
ircBot.messageQueue.add(new IRCMessage(target,
|
ircBot.messageQueue.add(new IRCMessage(target,
|
||||||
plugin.colorConverter.gameColorsToIrc(message), ctcpResponse));
|
plugin.colorConverter.gameColorsToIrc(message), type));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -76,15 +77,15 @@ public class IRCConsoleCommandSender implements ConsoleCommandSender {
|
|||||||
* @param ircBot
|
* @param ircBot
|
||||||
* @param target
|
* @param target
|
||||||
* @param plugin the PurpleIRC plugin
|
* @param plugin the PurpleIRC plugin
|
||||||
* @param ctcpResponse
|
* @param type
|
||||||
* @param name
|
* @param name
|
||||||
*/
|
*/
|
||||||
public IRCConsoleCommandSender(PurpleBot ircBot, String target, PurpleIRC plugin, boolean ctcpResponse, String name) {
|
public IRCConsoleCommandSender(PurpleBot ircBot, String target, PurpleIRC plugin, Type type, String name) {
|
||||||
super();
|
super();
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.ircBot = ircBot;
|
this.ircBot = ircBot;
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.ctcpResponse = ctcpResponse;
|
this.type = type;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,11 +24,17 @@ public class IRCMessage {
|
|||||||
|
|
||||||
public String target;
|
public String target;
|
||||||
public String message;
|
public String message;
|
||||||
public boolean ctcpResponse;
|
public Type type;
|
||||||
|
|
||||||
public IRCMessage(String target, String message, boolean ctcpResponse) {
|
public enum Type {
|
||||||
|
MESSAGE,
|
||||||
|
CTCP,
|
||||||
|
NOTICE
|
||||||
|
}
|
||||||
|
|
||||||
|
public IRCMessage(String target, String message, Type type) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.message = message;
|
this.message = message;
|
||||||
this.ctcpResponse = ctcpResponse;
|
this.type = type;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.cnaude.purpleirc;
|
package com.cnaude.purpleirc;
|
||||||
|
|
||||||
|
import com.cnaude.purpleirc.IRCMessage.Type;
|
||||||
import com.cnaude.purpleirc.Utilities.CaseInsensitiveMap;
|
import com.cnaude.purpleirc.Utilities.CaseInsensitiveMap;
|
||||||
import com.google.common.base.Joiner;
|
import com.google.common.base.Joiner;
|
||||||
import java.text.Collator;
|
import java.text.Collator;
|
||||||
@ -111,7 +112,7 @@ public class IRCMessageHandler {
|
|||||||
long coolDown;
|
long coolDown;
|
||||||
try {
|
try {
|
||||||
coolDown = Long.parseLong(ircBot.commandMap.get(channelName).get(command).get("cool_down"));
|
coolDown = Long.parseLong(ircBot.commandMap.get(channelName).get(command).get("cool_down"));
|
||||||
} catch (Exception ex) {
|
} catch (NumberFormatException ex) {
|
||||||
coolDown = 0;
|
coolDown = 0;
|
||||||
plugin.logError(ex.getMessage());
|
plugin.logError(ex.getMessage());
|
||||||
}
|
}
|
||||||
@ -121,7 +122,7 @@ public class IRCMessageHandler {
|
|||||||
if (coolDown != 1) {
|
if (coolDown != 1) {
|
||||||
s = "s";
|
s = "s";
|
||||||
}
|
}
|
||||||
sendMessage(ircBot, user.getNick(), "Cool down for this command triggered. Please wait at least " + coolDown + " second" + s + ".", true);
|
sendMessage(ircBot, user.getNick(), "Cool down for this command triggered. Please wait at least " + coolDown + " second" + s + ".", Type.CTCP);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -135,7 +136,14 @@ public class IRCMessageHandler {
|
|||||||
String perm = (String) ircBot.commandMap.get(channelName).get(command).get("perm");
|
String perm = (String) ircBot.commandMap.get(channelName).get(command).get("perm");
|
||||||
String outputTemplate = (String) ircBot.commandMap.get(channelName).get(command).get("output");
|
String outputTemplate = (String) ircBot.commandMap.get(channelName).get(command).get("output");
|
||||||
boolean privateCommand = Boolean.parseBoolean(ircBot.commandMap.get(channelName).get(command).get("private"));
|
boolean privateCommand = Boolean.parseBoolean(ircBot.commandMap.get(channelName).get(command).get("private"));
|
||||||
boolean ctcpResponse = Boolean.parseBoolean(ircBot.commandMap.get(channelName).get(command).get("ctcp"));
|
Type responseType = Type.MESSAGE;
|
||||||
|
if (Boolean.parseBoolean(ircBot.commandMap.get(channelName).get(command).get("ctcp"))) {
|
||||||
|
responseType = Type.CTCP;
|
||||||
|
}
|
||||||
|
if (Boolean.parseBoolean(ircBot.commandMap.get(channelName).get(command).get("notice"))) {
|
||||||
|
responseType = Type.NOTICE;
|
||||||
|
}
|
||||||
|
|
||||||
String senderName = ircBot.commandMap.get(channelName).get(command).get("sender").replace("%NICK%", user.getNick());
|
String senderName = ircBot.commandMap.get(channelName).get(command).get("sender").replace("%NICK%", user.getNick());
|
||||||
|
|
||||||
if (privateCommand || privateMessage) {
|
if (privateCommand || privateMessage) {
|
||||||
@ -151,28 +159,28 @@ public class IRCMessageHandler {
|
|||||||
for (String gameCommand : gameCommands) {
|
for (String gameCommand : gameCommands) {
|
||||||
switch (gameCommand) {
|
switch (gameCommand) {
|
||||||
case "@list":
|
case "@list":
|
||||||
sendMessage(ircBot, target, plugin.getMCPlayers(ircBot, channelName), ctcpResponse);
|
sendMessage(ircBot, target, plugin.getMCPlayers(ircBot, channelName), responseType);
|
||||||
break;
|
break;
|
||||||
case "@uptime":
|
case "@uptime":
|
||||||
sendMessage(ircBot, target, plugin.getMCUptime(), ctcpResponse);
|
sendMessage(ircBot, target, plugin.getMCUptime(), responseType);
|
||||||
break;
|
break;
|
||||||
case "@help":
|
case "@help":
|
||||||
sendMessage(ircBot, target, getCommands(ircBot.commandMap, channelName), ctcpResponse);
|
sendMessage(ircBot, target, getCommands(ircBot.commandMap, channelName), responseType);
|
||||||
break;
|
break;
|
||||||
case "@chat":
|
case "@chat":
|
||||||
ircBot.broadcastChat(user, channel, target, commandArgs, false, ctcpResponse);
|
ircBot.broadcastChat(user, channel, target, commandArgs, false, responseType);
|
||||||
break;
|
break;
|
||||||
case "@ochat":
|
case "@ochat":
|
||||||
ircBot.broadcastChat(user, channel, target, commandArgs, true, ctcpResponse);
|
ircBot.broadcastChat(user, channel, target, commandArgs, true, responseType);
|
||||||
break;
|
break;
|
||||||
case "@hchat":
|
case "@hchat":
|
||||||
ircBot.broadcastHeroChat(user, channel, target, commandArgs);
|
ircBot.broadcastHeroChat(user, channel, target, commandArgs);
|
||||||
break;
|
break;
|
||||||
case "@motd":
|
case "@motd":
|
||||||
sendMessage(ircBot, target, plugin.getServerMotd(), ctcpResponse);
|
sendMessage(ircBot, target, plugin.getServerMotd(), responseType);
|
||||||
break;
|
break;
|
||||||
case "@version":
|
case "@version":
|
||||||
sendMessage(ircBot, target, plugin.getServer().getVersion(), ctcpResponse);
|
sendMessage(ircBot, target, plugin.getServer().getVersion(), responseType);
|
||||||
break;
|
break;
|
||||||
case "@versionfull":
|
case "@versionfull":
|
||||||
String v = "This server is running "
|
String v = "This server is running "
|
||||||
@ -181,10 +189,10 @@ public class IRCMessageHandler {
|
|||||||
+ plugin.getServer().getVersion()
|
+ plugin.getServer().getVersion()
|
||||||
+ " (Implementing API version "
|
+ " (Implementing API version "
|
||||||
+ plugin.getServer().getBukkitVersion() + ")";
|
+ plugin.getServer().getBukkitVersion() + ")";
|
||||||
sendMessage(ircBot, target, v, ctcpResponse);
|
sendMessage(ircBot, target, v, responseType);
|
||||||
break;
|
break;
|
||||||
case "@bukkit":
|
case "@bukkit":
|
||||||
sendMessage(ircBot, target, plugin.getServer().getBukkitVersion(), ctcpResponse);
|
sendMessage(ircBot, target, plugin.getServer().getBukkitVersion(), responseType);
|
||||||
break;
|
break;
|
||||||
case "@rtsmb":
|
case "@rtsmb":
|
||||||
if (plugin.reportRTSHook != null) {
|
if (plugin.reportRTSHook != null) {
|
||||||
@ -198,11 +206,11 @@ public class IRCMessageHandler {
|
|||||||
ircBot.playerReplyChat(user, channel, target, commandArgs);
|
ircBot.playerReplyChat(user, channel, target, commandArgs);
|
||||||
break;
|
break;
|
||||||
case "@clearqueue":
|
case "@clearqueue":
|
||||||
sendMessage(ircBot, target, plugin.commandQueue.clearQueue(), ctcpResponse);
|
sendMessage(ircBot, target, plugin.commandQueue.clearQueue(), responseType);
|
||||||
sendMessage(ircBot, target, ircBot.messageQueue.clearQueue(), ctcpResponse);
|
sendMessage(ircBot, target, ircBot.messageQueue.clearQueue(), responseType);
|
||||||
break;
|
break;
|
||||||
case "@query":
|
case "@query":
|
||||||
sendMessage(ircBot, target, plugin.getRemotePlayers(commandArgs), ctcpResponse);
|
sendMessage(ircBot, target, plugin.getRemotePlayers(commandArgs), responseType);
|
||||||
break;
|
break;
|
||||||
case "@a":
|
case "@a":
|
||||||
if (plugin.adminPrivateChatHook != null && commandArgs != null) {
|
if (plugin.adminPrivateChatHook != null && commandArgs != null) {
|
||||||
@ -211,7 +219,7 @@ public class IRCMessageHandler {
|
|||||||
plugin.adminPrivateChatHook.sendMessage(newMessage, user.getNick());
|
plugin.adminPrivateChatHook.sendMessage(newMessage, user.getNick());
|
||||||
String acResponse = plugin.tokenizer.msgChatResponseTokenizer(target, commandArgs, plugin.getMessageTemplate(TemplateName.IRC_ADMIN_RESPONSE));
|
String acResponse = plugin.tokenizer.msgChatResponseTokenizer(target, commandArgs, plugin.getMessageTemplate(TemplateName.IRC_ADMIN_RESPONSE));
|
||||||
if (!acResponse.isEmpty()) {
|
if (!acResponse.isEmpty()) {
|
||||||
sendMessage(ircBot, target, acResponse, ctcpResponse);
|
sendMessage(ircBot, target, acResponse, responseType);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -257,8 +265,8 @@ public class IRCMessageHandler {
|
|||||||
plugin.logDebug("GM: \"" + gameCommand.trim() + "\"");
|
plugin.logDebug("GM: \"" + gameCommand.trim() + "\"");
|
||||||
try {
|
try {
|
||||||
plugin.commandQueue.add(new IRCCommand(
|
plugin.commandQueue.add(new IRCCommand(
|
||||||
new IRCCommandSender(ircBot, target, plugin, ctcpResponse, senderName, outputTemplate),
|
new IRCCommandSender(ircBot, target, plugin, responseType, senderName, outputTemplate),
|
||||||
new IRCConsoleCommandSender(ircBot, target, plugin, ctcpResponse, senderName),
|
new IRCConsoleCommandSender(ircBot, target, plugin, responseType, senderName),
|
||||||
gameCommand.trim()
|
gameCommand.trim()
|
||||||
));
|
));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
@ -294,7 +302,7 @@ public class IRCMessageHandler {
|
|||||||
}
|
}
|
||||||
if (ircBot.enabledMessages.get(channelName).contains(TemplateName.INVALID_IRC_COMMAND)) {
|
if (ircBot.enabledMessages.get(channelName).contains(TemplateName.INVALID_IRC_COMMAND)) {
|
||||||
plugin.logDebug("Invalid IRC command dispatched for broadcast...");
|
plugin.logDebug("Invalid IRC command dispatched for broadcast...");
|
||||||
ircBot.broadcastChat(user, channel, null, message, false, false);
|
ircBot.broadcastChat(user, channel, null, message, false, Type.MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -310,7 +318,7 @@ public class IRCMessageHandler {
|
|||||||
if (plugin.stripGameColorsFromIrc) {
|
if (plugin.stripGameColorsFromIrc) {
|
||||||
message = ChatColor.stripColor(message);
|
message = ChatColor.stripColor(message);
|
||||||
}
|
}
|
||||||
ircBot.broadcastChat(user, channel, null, message, false, false);
|
ircBot.broadcastChat(user, channel, null, message, false, Type.MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,13 +349,20 @@ public class IRCMessageHandler {
|
|||||||
return modeOkay;
|
return modeOkay;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessage(PurpleBot ircBot, String target, String message, boolean ctcpResponse) {
|
private void sendMessage(PurpleBot ircBot, String target, String message, Type responseType) {
|
||||||
if (ctcpResponse) {
|
switch (responseType) {
|
||||||
|
case CTCP:
|
||||||
plugin.logDebug("Sending message to target: " + target + " => " + message);
|
plugin.logDebug("Sending message to target: " + target + " => " + message);
|
||||||
ircBot.asyncCTCPMessage(target, message);
|
ircBot.asyncCTCPMessage(target, message);
|
||||||
} else {
|
break;
|
||||||
|
case MESSAGE:
|
||||||
plugin.logDebug("Sending message to target: " + target + " => " + message);
|
plugin.logDebug("Sending message to target: " + target + " => " + message);
|
||||||
ircBot.asyncIRCMessage(target, message);
|
ircBot.asyncIRCMessage(target, message);
|
||||||
|
break;
|
||||||
|
case NOTICE:
|
||||||
|
plugin.logDebug("Sending notice to target: " + target + " => " + message);
|
||||||
|
ircBot.asyncNoticeMessage(target, message);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,10 +65,15 @@ public class IRCMessageQueueWatcher {
|
|||||||
if (ircMessage != null) {
|
if (ircMessage != null) {
|
||||||
plugin.logDebug("[" + queue.size() + "]: queueAndSend message detected");
|
plugin.logDebug("[" + queue.size() + "]: queueAndSend message detected");
|
||||||
for (String s : cleanupAndSplitMessage(ircMessage.message)) {
|
for (String s : cleanupAndSplitMessage(ircMessage.message)) {
|
||||||
if (ircMessage.ctcpResponse) {
|
switch (ircMessage.type) {
|
||||||
blockingCTCPMessage(ircMessage.target, s);
|
case MESSAGE:
|
||||||
} else {
|
|
||||||
blockingIRCMessage(ircMessage.target, s);
|
blockingIRCMessage(ircMessage.target, s);
|
||||||
|
break;
|
||||||
|
case CTCP:
|
||||||
|
blockingCTCPMessage(ircMessage.target, s);
|
||||||
|
break;
|
||||||
|
case NOTICE:
|
||||||
|
blockingNoticeMessage(ircMessage.target, s);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -92,6 +97,15 @@ public class IRCMessageQueueWatcher {
|
|||||||
plugin.logDebug("[blockingCTCPMessage] Message sent to " + target + ": " + message);
|
plugin.logDebug("[blockingCTCPMessage] Message sent to " + target + ": " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void blockingNoticeMessage(final String target, final String message) {
|
||||||
|
if (!ircBot.isConnected()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
plugin.logDebug("[blockingNoticeMessage] About to send IRC notice to " + target + ": " + message);
|
||||||
|
ircBot.bot.sendIRC().notice(target, message);
|
||||||
|
plugin.logDebug("[blockingNoticeMessage] Notice sent to " + target + ": " + message);
|
||||||
|
}
|
||||||
|
|
||||||
private String pingFix(String message) {
|
private String pingFix(String message) {
|
||||||
try {
|
try {
|
||||||
for (Channel channel : ircBot.bot.getUserBot().getChannels()) {
|
for (Channel channel : ircBot.bot.getUserBot().getChannels()) {
|
||||||
|
@ -34,6 +34,10 @@ import com.cnaude.purpleirc.IRCListeners.QuitListener;
|
|||||||
import com.cnaude.purpleirc.IRCListeners.ServerResponseListener;
|
import com.cnaude.purpleirc.IRCListeners.ServerResponseListener;
|
||||||
import com.cnaude.purpleirc.IRCListeners.TopicListener;
|
import com.cnaude.purpleirc.IRCListeners.TopicListener;
|
||||||
import com.cnaude.purpleirc.IRCListeners.WhoisListener;
|
import com.cnaude.purpleirc.IRCListeners.WhoisListener;
|
||||||
|
import com.cnaude.purpleirc.IRCMessage.Type;
|
||||||
|
import static com.cnaude.purpleirc.IRCMessage.Type.CTCP;
|
||||||
|
import static com.cnaude.purpleirc.IRCMessage.Type.MESSAGE;
|
||||||
|
import static com.cnaude.purpleirc.IRCMessage.Type.NOTICE;
|
||||||
import com.cnaude.purpleirc.Utilities.CaseInsensitiveMap;
|
import com.cnaude.purpleirc.Utilities.CaseInsensitiveMap;
|
||||||
import com.dthielke.herochat.Herochat;
|
import com.dthielke.herochat.Herochat;
|
||||||
import com.dthielke.herochat.Chatter;
|
import com.dthielke.herochat.Chatter;
|
||||||
@ -183,6 +187,8 @@ public final class PurpleBot {
|
|||||||
boolean joinNoticeEnabled;
|
boolean joinNoticeEnabled;
|
||||||
boolean joinNoticePrivate;
|
boolean joinNoticePrivate;
|
||||||
boolean joinNoticeCtcp;
|
boolean joinNoticeCtcp;
|
||||||
|
boolean joinNoticeNotice;
|
||||||
|
Type joinResponseType;
|
||||||
String joinNoticeMessage;
|
String joinNoticeMessage;
|
||||||
String version;
|
String version;
|
||||||
String finger;
|
String finger;
|
||||||
@ -559,13 +565,19 @@ public final class PurpleBot {
|
|||||||
|
|
||||||
public void asyncIRCMessage(final String target, final String message) {
|
public void asyncIRCMessage(final String target, final String message) {
|
||||||
plugin.logDebug("Entering aysncIRCMessage");
|
plugin.logDebug("Entering aysncIRCMessage");
|
||||||
IRCMessage ircMessage = new IRCMessage(target, plugin.colorConverter.gameColorsToIrc(message), false);
|
IRCMessage ircMessage = new IRCMessage(target, plugin.colorConverter.gameColorsToIrc(message), MESSAGE);
|
||||||
messageQueue.add(ircMessage);
|
messageQueue.add(ircMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void asyncCTCPMessage(final String target, final String message) {
|
public void asyncCTCPMessage(final String target, final String message) {
|
||||||
plugin.logDebug("Entering asyncCTCPMessage");
|
plugin.logDebug("Entering asyncCTCPMessage");
|
||||||
IRCMessage ircMessage = new IRCMessage(target, plugin.colorConverter.gameColorsToIrc(message), true);
|
IRCMessage ircMessage = new IRCMessage(target, plugin.colorConverter.gameColorsToIrc(message), CTCP);
|
||||||
|
messageQueue.add(ircMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void asyncNoticeMessage(final String target, final String message) {
|
||||||
|
plugin.logDebug("Entering asyncNoticeMessage");
|
||||||
|
IRCMessage ircMessage = new IRCMessage(target, plugin.colorConverter.gameColorsToIrc(message), NOTICE);
|
||||||
messageQueue.add(ircMessage);
|
messageQueue.add(ircMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1137,8 +1149,16 @@ public final class PurpleBot {
|
|||||||
joinNoticeCoolDown = config.getInt("channels." + enChannelName + ".join-notice.cooldown", 60);
|
joinNoticeCoolDown = config.getInt("channels." + enChannelName + ".join-notice.cooldown", 60);
|
||||||
joinNoticeEnabled = config.getBoolean("channels." + enChannelName + ".join-notice.enabled", false);
|
joinNoticeEnabled = config.getBoolean("channels." + enChannelName + ".join-notice.enabled", false);
|
||||||
joinNoticePrivate = config.getBoolean("channels." + enChannelName + ".join-notice.private", true);
|
joinNoticePrivate = config.getBoolean("channels." + enChannelName + ".join-notice.private", true);
|
||||||
joinNoticeCtcp = config.getBoolean("channels." + enChannelName + ".join-notice.ctcp", true);
|
|
||||||
joinNoticeMessage = config.getString("channels." + enChannelName + ".join-notice.message", "");
|
joinNoticeMessage = config.getString("channels." + enChannelName + ".join-notice.message", "");
|
||||||
|
|
||||||
|
joinResponseType = Type.MESSAGE;
|
||||||
|
if (config.getBoolean("channels." + enChannelName + ".join-notice.ctcp", true)) {
|
||||||
|
joinResponseType = Type.CTCP;
|
||||||
|
}
|
||||||
|
if (config.getBoolean("channels." + enChannelName + ".join-notice.notice", false)) {
|
||||||
|
joinResponseType = Type.NOTICE;
|
||||||
|
}
|
||||||
|
|
||||||
plugin.logDebug("join-notice.cooldown: " + joinNoticeCoolDown);
|
plugin.logDebug("join-notice.cooldown: " + joinNoticeCoolDown);
|
||||||
plugin.logDebug("join-notice.enabled: " + joinNoticeEnabled);
|
plugin.logDebug("join-notice.enabled: " + joinNoticeEnabled);
|
||||||
plugin.logDebug("join-notice.private: " + joinNoticePrivate);
|
plugin.logDebug("join-notice.private: " + joinNoticePrivate);
|
||||||
@ -2702,9 +2722,9 @@ public final class PurpleBot {
|
|||||||
* @param target
|
* @param target
|
||||||
* @param message
|
* @param message
|
||||||
* @param override
|
* @param override
|
||||||
* @param ctcpResponse
|
* @param responseType
|
||||||
*/
|
*/
|
||||||
public void broadcastChat(User user, org.pircbotx.Channel channel, String target, String message, boolean override, boolean ctcpResponse) {
|
public void broadcastChat(User user, org.pircbotx.Channel channel, String target, String message, boolean override, Type responseType) {
|
||||||
boolean messageSent = false;
|
boolean messageSent = false;
|
||||||
String channelName = channel.getName();
|
String channelName = channel.getName();
|
||||||
|
|
||||||
@ -2916,10 +2936,16 @@ public final class PurpleBot {
|
|||||||
// Let the sender know the message was sent
|
// Let the sender know the message was sent
|
||||||
String responseTemplate = plugin.getMessageTemplate(botNick, channelName, TemplateName.IRC_CHAT_RESPONSE);
|
String responseTemplate = plugin.getMessageTemplate(botNick, channelName, TemplateName.IRC_CHAT_RESPONSE);
|
||||||
if (!responseTemplate.isEmpty()) {
|
if (!responseTemplate.isEmpty()) {
|
||||||
if (ctcpResponse) {
|
switch (responseType) {
|
||||||
|
case CTCP:
|
||||||
asyncCTCPMessage(target, plugin.tokenizer.targetChatResponseTokenizer(target, message, responseTemplate));
|
asyncCTCPMessage(target, plugin.tokenizer.targetChatResponseTokenizer(target, message, responseTemplate));
|
||||||
} else {
|
break;
|
||||||
|
case MESSAGE:
|
||||||
asyncIRCMessage(target, plugin.tokenizer.targetChatResponseTokenizer(target, message, responseTemplate));
|
asyncIRCMessage(target, plugin.tokenizer.targetChatResponseTokenizer(target, message, responseTemplate));
|
||||||
|
break;
|
||||||
|
case NOTICE:
|
||||||
|
asyncNoticeMessage(target, plugin.tokenizer.targetChatResponseTokenizer(target, message, responseTemplate));
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3866,8 +3892,8 @@ public final class PurpleBot {
|
|||||||
String myMessage = ChatColor.translateAlternateColorCodes('&', plugin.colorConverter.gameColorsToIrc(joinNoticeMessage.replace("%NAME%", user.getNick())));
|
String myMessage = ChatColor.translateAlternateColorCodes('&', plugin.colorConverter.gameColorsToIrc(joinNoticeMessage.replace("%NAME%", user.getNick())));
|
||||||
if (joinNoticeMessage.startsWith("/")) {
|
if (joinNoticeMessage.startsWith("/")) {
|
||||||
plugin.commandQueue.add(new IRCCommand(
|
plugin.commandQueue.add(new IRCCommand(
|
||||||
new IRCCommandSender(this, target, plugin, joinNoticeCtcp, "CONSOLE", "%RESULT%"),
|
new IRCCommandSender(this, target, plugin, joinResponseType, "CONSOLE", "%RESULT%"),
|
||||||
new IRCConsoleCommandSender(this, target, plugin, joinNoticeCtcp, "CONSOLE"),
|
new IRCConsoleCommandSender(this, target, plugin, joinResponseType, "CONSOLE"),
|
||||||
myMessage.trim().substring(1)));
|
myMessage.trim().substring(1)));
|
||||||
} else if (joinNoticeCtcp) {
|
} else if (joinNoticeCtcp) {
|
||||||
asyncCTCPMessage(target, myMessage);
|
asyncCTCPMessage(target, myMessage);
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2015 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.Utilities;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
|
import com.google.common.base.Charsets;
|
||||||
|
import com.mojang.authlib.GameProfile;
|
||||||
|
import java.util.UUID;
|
||||||
|
import net.minecraft.server.v1_11_R1.EntityPlayer;
|
||||||
|
import net.minecraft.server.v1_11_R1.MinecraftServer;
|
||||||
|
import net.minecraft.server.v1_11_R1.PacketPlayOutPlayerInfo;
|
||||||
|
import net.minecraft.server.v1_11_R1.PlayerInteractManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author Chris Naude
|
||||||
|
*/
|
||||||
|
public class NetPacket_111 {
|
||||||
|
|
||||||
|
public static PacketContainer add(String displayName) {
|
||||||
|
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + displayName).getBytes(Charsets.UTF_8));
|
||||||
|
EntityPlayer pl = new EntityPlayer(
|
||||||
|
MinecraftServer.getServer(),
|
||||||
|
MinecraftServer.getServer().getWorldServer(0),
|
||||||
|
(GameProfile) (new WrappedGameProfile(uuid, displayName)).getHandle(),
|
||||||
|
new PlayerInteractManager(MinecraftServer.getServer().getWorldServer(0))
|
||||||
|
);
|
||||||
|
PacketPlayOutPlayerInfo pi
|
||||||
|
= new PacketPlayOutPlayerInfo(
|
||||||
|
PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, pl);
|
||||||
|
return PacketContainer.fromPacket(pi);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PacketContainer rem(String displayName) {
|
||||||
|
UUID uuid = UUID.nameUUIDFromBytes(("OfflinePlayer:" + displayName).getBytes(Charsets.UTF_8));
|
||||||
|
EntityPlayer pl = new EntityPlayer(
|
||||||
|
MinecraftServer.getServer(),
|
||||||
|
MinecraftServer.getServer().getWorldServer(0),
|
||||||
|
(GameProfile) (new WrappedGameProfile(uuid, displayName)).getHandle(),
|
||||||
|
new PlayerInteractManager(MinecraftServer.getServer().getWorldServer(0))
|
||||||
|
);
|
||||||
|
PacketPlayOutPlayerInfo pi
|
||||||
|
= new PacketPlayOutPlayerInfo(
|
||||||
|
PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, pl);
|
||||||
|
return PacketContainer.fromPacket(pi);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -183,6 +183,17 @@ public class NetPackets {
|
|||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
plugin.logError("tabPacket: " + ex.getMessage());
|
plugin.logError("tabPacket: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
} else if (version.contains("MC: 1.11")) {
|
||||||
|
try {
|
||||||
|
if (add) {
|
||||||
|
return NetPacket_111.add(displayName);
|
||||||
|
} else {
|
||||||
|
plugin.logDebug("T111: Removing: " + name);
|
||||||
|
return NetPacket_111.rem(displayName);
|
||||||
|
}
|
||||||
|
} catch (Exception ex) {
|
||||||
|
plugin.logError("tabPacket: " + ex.getMessage());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
plugin.logDebug("tabPacket: deprecated ");
|
plugin.logDebug("tabPacket: deprecated ");
|
||||||
playerListConstructor = protocolManager.createPacketConstructor(Packets.Server.PLAYER_INFO, "", false, (int) 0);
|
playerListConstructor = protocolManager.createPacketConstructor(Packets.Server.PLAYER_INFO, "", false, (int) 0);
|
||||||
|
@ -326,6 +326,8 @@ channels:
|
|||||||
private: true
|
private: true
|
||||||
# If true then message will be sent via ctcp. if false then normal msg
|
# If true then message will be sent via ctcp. if false then normal msg
|
||||||
ctcp: true
|
ctcp: true
|
||||||
|
# send a notice message (overrides ctcp)
|
||||||
|
notice: false
|
||||||
# The actual message sent to the user when joining the channel.
|
# The actual message sent to the user when joining the channel.
|
||||||
# If the message starts with a / then a command will be run and the output sent as the message.
|
# If the message starts with a / then a command will be run and the output sent as the message.
|
||||||
message: '/list'
|
message: '/list'
|
||||||
@ -354,6 +356,7 @@ channels:
|
|||||||
modes: '*'
|
modes: '*'
|
||||||
private: false
|
private: false
|
||||||
ctcp: false
|
ctcp: false
|
||||||
|
notice: false
|
||||||
game_command: '@chat'
|
game_command: '@chat'
|
||||||
extras_commands: []
|
extras_commands: []
|
||||||
private_listen: true
|
private_listen: true
|
||||||
@ -366,6 +369,7 @@ channels:
|
|||||||
modes: '*'
|
modes: '*'
|
||||||
private: false
|
private: false
|
||||||
ctcp: false
|
ctcp: false
|
||||||
|
notice: false
|
||||||
game_command: '@ochat'
|
game_command: '@ochat'
|
||||||
extras_commands: []
|
extras_commands: []
|
||||||
private_listen: true
|
private_listen: true
|
||||||
@ -378,6 +382,7 @@ channels:
|
|||||||
modes: '*'
|
modes: '*'
|
||||||
private: false
|
private: false
|
||||||
ctcp: false
|
ctcp: false
|
||||||
|
notice: false
|
||||||
game_command: '@hchat'
|
game_command: '@hchat'
|
||||||
extras_commands: []
|
extras_commands: []
|
||||||
private_listen: true
|
private_listen: true
|
||||||
@ -390,6 +395,7 @@ channels:
|
|||||||
modes: '*'
|
modes: '*'
|
||||||
private: true
|
private: true
|
||||||
ctcp: false
|
ctcp: false
|
||||||
|
notice: false
|
||||||
game_command: '@msg'
|
game_command: '@msg'
|
||||||
extras_commands: []
|
extras_commands: []
|
||||||
private_listen: true
|
private_listen: true
|
||||||
@ -402,6 +408,7 @@ channels:
|
|||||||
modes: '*'
|
modes: '*'
|
||||||
private: 'true'
|
private: 'true'
|
||||||
ctcp: 'false'
|
ctcp: 'false'
|
||||||
|
notice: false
|
||||||
game_command: '@r'
|
game_command: '@r'
|
||||||
private_listen: 'true'
|
private_listen: 'true'
|
||||||
channel_listen: 'true'
|
channel_listen: 'true'
|
||||||
@ -416,6 +423,7 @@ channels:
|
|||||||
modes: '*'
|
modes: '*'
|
||||||
private: false
|
private: false
|
||||||
ctcp: false
|
ctcp: false
|
||||||
|
notice: false
|
||||||
game_command: '@list'
|
game_command: '@list'
|
||||||
extras_commands: []
|
extras_commands: []
|
||||||
private_listen: true
|
private_listen: true
|
||||||
@ -428,6 +436,7 @@ channels:
|
|||||||
modes: '*'
|
modes: '*'
|
||||||
private: false
|
private: false
|
||||||
ctcp: false
|
ctcp: false
|
||||||
|
notice: false
|
||||||
game_command: '@help'
|
game_command: '@help'
|
||||||
extras_commands: []
|
extras_commands: []
|
||||||
private_listen: true
|
private_listen: true
|
||||||
@ -440,6 +449,7 @@ channels:
|
|||||||
modes: '*'
|
modes: '*'
|
||||||
private: false
|
private: false
|
||||||
ctcp: false
|
ctcp: false
|
||||||
|
notice: false
|
||||||
game_command: '@uptime'
|
game_command: '@uptime'
|
||||||
extras_commands: []
|
extras_commands: []
|
||||||
private_listen: true
|
private_listen: true
|
||||||
@ -452,6 +462,7 @@ channels:
|
|||||||
modes: '*'
|
modes: '*'
|
||||||
private: false
|
private: false
|
||||||
ctcp: false
|
ctcp: false
|
||||||
|
notice: false
|
||||||
game_command: '@versionfull'
|
game_command: '@versionfull'
|
||||||
extras_commands: []
|
extras_commands: []
|
||||||
private_listen: true
|
private_listen: true
|
||||||
@ -464,6 +475,7 @@ channels:
|
|||||||
modes: '*'
|
modes: '*'
|
||||||
private: false
|
private: false
|
||||||
ctcp: false
|
ctcp: false
|
||||||
|
notice: false
|
||||||
game_command: lag
|
game_command: lag
|
||||||
extras_commands: []
|
extras_commands: []
|
||||||
private_listen: true
|
private_listen: true
|
||||||
@ -476,6 +488,7 @@ channels:
|
|||||||
modes: 'o'
|
modes: 'o'
|
||||||
private: 'false'
|
private: 'false'
|
||||||
ctcp: 'false'
|
ctcp: 'false'
|
||||||
|
notice: false
|
||||||
game_command: '@list'
|
game_command: '@list'
|
||||||
extra_commands:
|
extra_commands:
|
||||||
- '@version'
|
- '@version'
|
||||||
|
Loading…
Reference in New Issue
Block a user