mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-26 03:55:55 +01: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>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<!-- 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>
|
||||
</properties>
|
||||
|
||||
@ -140,6 +140,14 @@
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>spigot-111</artifactId>
|
||||
<version>1.11</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- PircBotX -->
|
||||
<dependency>
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.cnaude.purpleirc;
|
||||
|
||||
import com.cnaude.purpleirc.IRCMessage.Type;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
@ -35,7 +36,7 @@ public class IRCCommandSender implements CommandSender {
|
||||
private final PurpleBot ircBot;
|
||||
private final String target;
|
||||
private final PurpleIRC plugin;
|
||||
private final boolean ctcpResponse;
|
||||
private final Type responseType;
|
||||
private final String name;
|
||||
private final String template;
|
||||
|
||||
@ -67,7 +68,7 @@ public class IRCCommandSender implements CommandSender {
|
||||
|
||||
private void addMessageToQueue(String message) {
|
||||
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 target
|
||||
* @param plugin the PurpleIRC plugin
|
||||
* @param ctcpResponse
|
||||
* @param responseType
|
||||
* @param name
|
||||
* @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();
|
||||
this.target = target;
|
||||
this.ircBot = ircBot;
|
||||
this.plugin = plugin;
|
||||
this.ctcpResponse = ctcpResponse;
|
||||
this.responseType = responseType;
|
||||
this.name = name;
|
||||
this.template = template;
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.cnaude.purpleirc;
|
||||
|
||||
import com.cnaude.purpleirc.IRCMessage.Type;
|
||||
import java.util.Set;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Server;
|
||||
@ -37,7 +38,7 @@ public class IRCConsoleCommandSender implements ConsoleCommandSender {
|
||||
private final PurpleBot ircBot;
|
||||
private final String target;
|
||||
private final PurpleIRC plugin;
|
||||
private final boolean ctcpResponse;
|
||||
private final Type type;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
@ -68,7 +69,7 @@ public class IRCConsoleCommandSender implements ConsoleCommandSender {
|
||||
|
||||
private void addMessageToQueue(String message) {
|
||||
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 target
|
||||
* @param plugin the PurpleIRC plugin
|
||||
* @param ctcpResponse
|
||||
* @param type
|
||||
* @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();
|
||||
this.target = target;
|
||||
this.ircBot = ircBot;
|
||||
this.plugin = plugin;
|
||||
this.ctcpResponse = ctcpResponse;
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
@ -24,11 +24,17 @@ public class IRCMessage {
|
||||
|
||||
public String target;
|
||||
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.message = message;
|
||||
this.ctcpResponse = ctcpResponse;
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package com.cnaude.purpleirc;
|
||||
|
||||
import com.cnaude.purpleirc.IRCMessage.Type;
|
||||
import com.cnaude.purpleirc.Utilities.CaseInsensitiveMap;
|
||||
import com.google.common.base.Joiner;
|
||||
import java.text.Collator;
|
||||
@ -111,7 +112,7 @@ public class IRCMessageHandler {
|
||||
long coolDown;
|
||||
try {
|
||||
coolDown = Long.parseLong(ircBot.commandMap.get(channelName).get(command).get("cool_down"));
|
||||
} catch (Exception ex) {
|
||||
} catch (NumberFormatException ex) {
|
||||
coolDown = 0;
|
||||
plugin.logError(ex.getMessage());
|
||||
}
|
||||
@ -121,7 +122,7 @@ public class IRCMessageHandler {
|
||||
if (coolDown != 1) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -135,7 +136,14 @@ public class IRCMessageHandler {
|
||||
String perm = (String) ircBot.commandMap.get(channelName).get(command).get("perm");
|
||||
String outputTemplate = (String) ircBot.commandMap.get(channelName).get(command).get("output");
|
||||
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());
|
||||
|
||||
if (privateCommand || privateMessage) {
|
||||
@ -151,28 +159,28 @@ public class IRCMessageHandler {
|
||||
for (String gameCommand : gameCommands) {
|
||||
switch (gameCommand) {
|
||||
case "@list":
|
||||
sendMessage(ircBot, target, plugin.getMCPlayers(ircBot, channelName), ctcpResponse);
|
||||
sendMessage(ircBot, target, plugin.getMCPlayers(ircBot, channelName), responseType);
|
||||
break;
|
||||
case "@uptime":
|
||||
sendMessage(ircBot, target, plugin.getMCUptime(), ctcpResponse);
|
||||
sendMessage(ircBot, target, plugin.getMCUptime(), responseType);
|
||||
break;
|
||||
case "@help":
|
||||
sendMessage(ircBot, target, getCommands(ircBot.commandMap, channelName), ctcpResponse);
|
||||
sendMessage(ircBot, target, getCommands(ircBot.commandMap, channelName), responseType);
|
||||
break;
|
||||
case "@chat":
|
||||
ircBot.broadcastChat(user, channel, target, commandArgs, false, ctcpResponse);
|
||||
ircBot.broadcastChat(user, channel, target, commandArgs, false, responseType);
|
||||
break;
|
||||
case "@ochat":
|
||||
ircBot.broadcastChat(user, channel, target, commandArgs, true, ctcpResponse);
|
||||
ircBot.broadcastChat(user, channel, target, commandArgs, true, responseType);
|
||||
break;
|
||||
case "@hchat":
|
||||
ircBot.broadcastHeroChat(user, channel, target, commandArgs);
|
||||
break;
|
||||
case "@motd":
|
||||
sendMessage(ircBot, target, plugin.getServerMotd(), ctcpResponse);
|
||||
sendMessage(ircBot, target, plugin.getServerMotd(), responseType);
|
||||
break;
|
||||
case "@version":
|
||||
sendMessage(ircBot, target, plugin.getServer().getVersion(), ctcpResponse);
|
||||
sendMessage(ircBot, target, plugin.getServer().getVersion(), responseType);
|
||||
break;
|
||||
case "@versionfull":
|
||||
String v = "This server is running "
|
||||
@ -181,10 +189,10 @@ public class IRCMessageHandler {
|
||||
+ plugin.getServer().getVersion()
|
||||
+ " (Implementing API version "
|
||||
+ plugin.getServer().getBukkitVersion() + ")";
|
||||
sendMessage(ircBot, target, v, ctcpResponse);
|
||||
sendMessage(ircBot, target, v, responseType);
|
||||
break;
|
||||
case "@bukkit":
|
||||
sendMessage(ircBot, target, plugin.getServer().getBukkitVersion(), ctcpResponse);
|
||||
sendMessage(ircBot, target, plugin.getServer().getBukkitVersion(), responseType);
|
||||
break;
|
||||
case "@rtsmb":
|
||||
if (plugin.reportRTSHook != null) {
|
||||
@ -198,11 +206,11 @@ public class IRCMessageHandler {
|
||||
ircBot.playerReplyChat(user, channel, target, commandArgs);
|
||||
break;
|
||||
case "@clearqueue":
|
||||
sendMessage(ircBot, target, plugin.commandQueue.clearQueue(), ctcpResponse);
|
||||
sendMessage(ircBot, target, ircBot.messageQueue.clearQueue(), ctcpResponse);
|
||||
sendMessage(ircBot, target, plugin.commandQueue.clearQueue(), responseType);
|
||||
sendMessage(ircBot, target, ircBot.messageQueue.clearQueue(), responseType);
|
||||
break;
|
||||
case "@query":
|
||||
sendMessage(ircBot, target, plugin.getRemotePlayers(commandArgs), ctcpResponse);
|
||||
sendMessage(ircBot, target, plugin.getRemotePlayers(commandArgs), responseType);
|
||||
break;
|
||||
case "@a":
|
||||
if (plugin.adminPrivateChatHook != null && commandArgs != null) {
|
||||
@ -211,7 +219,7 @@ public class IRCMessageHandler {
|
||||
plugin.adminPrivateChatHook.sendMessage(newMessage, user.getNick());
|
||||
String acResponse = plugin.tokenizer.msgChatResponseTokenizer(target, commandArgs, plugin.getMessageTemplate(TemplateName.IRC_ADMIN_RESPONSE));
|
||||
if (!acResponse.isEmpty()) {
|
||||
sendMessage(ircBot, target, acResponse, ctcpResponse);
|
||||
sendMessage(ircBot, target, acResponse, responseType);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -257,8 +265,8 @@ public class IRCMessageHandler {
|
||||
plugin.logDebug("GM: \"" + gameCommand.trim() + "\"");
|
||||
try {
|
||||
plugin.commandQueue.add(new IRCCommand(
|
||||
new IRCCommandSender(ircBot, target, plugin, ctcpResponse, senderName, outputTemplate),
|
||||
new IRCConsoleCommandSender(ircBot, target, plugin, ctcpResponse, senderName),
|
||||
new IRCCommandSender(ircBot, target, plugin, responseType, senderName, outputTemplate),
|
||||
new IRCConsoleCommandSender(ircBot, target, plugin, responseType, senderName),
|
||||
gameCommand.trim()
|
||||
));
|
||||
} catch (Exception ex) {
|
||||
@ -294,7 +302,7 @@ public class IRCMessageHandler {
|
||||
}
|
||||
if (ircBot.enabledMessages.get(channelName).contains(TemplateName.INVALID_IRC_COMMAND)) {
|
||||
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 {
|
||||
@ -310,7 +318,7 @@ public class IRCMessageHandler {
|
||||
if (plugin.stripGameColorsFromIrc) {
|
||||
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;
|
||||
}
|
||||
|
||||
private void sendMessage(PurpleBot ircBot, String target, String message, boolean ctcpResponse) {
|
||||
if (ctcpResponse) {
|
||||
plugin.logDebug("Sending message to target: " + target + " => " + message);
|
||||
ircBot.asyncCTCPMessage(target, message);
|
||||
} else {
|
||||
plugin.logDebug("Sending message to target: " + target + " => " + message);
|
||||
ircBot.asyncIRCMessage(target, message);
|
||||
private void sendMessage(PurpleBot ircBot, String target, String message, Type responseType) {
|
||||
switch (responseType) {
|
||||
case CTCP:
|
||||
plugin.logDebug("Sending message to target: " + target + " => " + message);
|
||||
ircBot.asyncCTCPMessage(target, message);
|
||||
break;
|
||||
case MESSAGE:
|
||||
plugin.logDebug("Sending message to target: " + 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) {
|
||||
plugin.logDebug("[" + queue.size() + "]: queueAndSend message detected");
|
||||
for (String s : cleanupAndSplitMessage(ircMessage.message)) {
|
||||
if (ircMessage.ctcpResponse) {
|
||||
blockingCTCPMessage(ircMessage.target, s);
|
||||
} else {
|
||||
blockingIRCMessage(ircMessage.target, s);
|
||||
switch (ircMessage.type) {
|
||||
case MESSAGE:
|
||||
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);
|
||||
}
|
||||
|
||||
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) {
|
||||
try {
|
||||
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.TopicListener;
|
||||
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.dthielke.herochat.Herochat;
|
||||
import com.dthielke.herochat.Chatter;
|
||||
@ -183,6 +187,8 @@ public final class PurpleBot {
|
||||
boolean joinNoticeEnabled;
|
||||
boolean joinNoticePrivate;
|
||||
boolean joinNoticeCtcp;
|
||||
boolean joinNoticeNotice;
|
||||
Type joinResponseType;
|
||||
String joinNoticeMessage;
|
||||
String version;
|
||||
String finger;
|
||||
@ -559,13 +565,19 @@ public final class PurpleBot {
|
||||
|
||||
public void asyncIRCMessage(final String target, final String message) {
|
||||
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);
|
||||
}
|
||||
|
||||
public void asyncCTCPMessage(final String target, final String message) {
|
||||
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);
|
||||
}
|
||||
|
||||
@ -951,7 +963,7 @@ public final class PurpleBot {
|
||||
|
||||
townyChannel.put(channelName, config.getString("channels." + enChannelName + ".towny-channel", ""));
|
||||
plugin.logDebug(" TownyChannel => " + townyChannel.get(channelName));
|
||||
|
||||
|
||||
discordChannel.put(channelName, config.getString("channels." + enChannelName + ".discord-channel", ""));
|
||||
plugin.logDebug(" DiscordChannel => " + discordChannel.get(channelName));
|
||||
|
||||
@ -1137,8 +1149,16 @@ public final class PurpleBot {
|
||||
joinNoticeCoolDown = config.getInt("channels." + enChannelName + ".join-notice.cooldown", 60);
|
||||
joinNoticeEnabled = config.getBoolean("channels." + enChannelName + ".join-notice.enabled", false);
|
||||
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", "");
|
||||
|
||||
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.enabled: " + joinNoticeEnabled);
|
||||
plugin.logDebug("join-notice.private: " + joinNoticePrivate);
|
||||
@ -2355,7 +2375,7 @@ public final class PurpleBot {
|
||||
+ " IRC topic for " + ChatColor.WHITE + channelName
|
||||
+ ChatColor.RESET + ": \""
|
||||
+ ChatColor.WHITE + plugin.colorConverter
|
||||
.ircColorsToGame(activeTopic.get(channelName))
|
||||
.ircColorsToGame(activeTopic.get(channelName))
|
||||
+ ChatColor.RESET + "\"");
|
||||
}
|
||||
}
|
||||
@ -2702,9 +2722,9 @@ public final class PurpleBot {
|
||||
* @param target
|
||||
* @param message
|
||||
* @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;
|
||||
String channelName = channel.getName();
|
||||
|
||||
@ -2893,7 +2913,7 @@ public final class PurpleBot {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Send messages to VentureChat if enabled
|
||||
*/
|
||||
@ -2916,10 +2936,16 @@ public final class PurpleBot {
|
||||
// Let the sender know the message was sent
|
||||
String responseTemplate = plugin.getMessageTemplate(botNick, channelName, TemplateName.IRC_CHAT_RESPONSE);
|
||||
if (!responseTemplate.isEmpty()) {
|
||||
if (ctcpResponse) {
|
||||
asyncCTCPMessage(target, plugin.tokenizer.targetChatResponseTokenizer(target, message, responseTemplate));
|
||||
} else {
|
||||
asyncIRCMessage(target, plugin.tokenizer.targetChatResponseTokenizer(target, message, responseTemplate));
|
||||
switch (responseType) {
|
||||
case CTCP:
|
||||
asyncCTCPMessage(target, plugin.tokenizer.targetChatResponseTokenizer(target, message, responseTemplate));
|
||||
break;
|
||||
case MESSAGE:
|
||||
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())));
|
||||
if (joinNoticeMessage.startsWith("/")) {
|
||||
plugin.commandQueue.add(new IRCCommand(
|
||||
new IRCCommandSender(this, target, plugin, joinNoticeCtcp, "CONSOLE", "%RESULT%"),
|
||||
new IRCConsoleCommandSender(this, target, plugin, joinNoticeCtcp, "CONSOLE"),
|
||||
new IRCCommandSender(this, target, plugin, joinResponseType, "CONSOLE", "%RESULT%"),
|
||||
new IRCConsoleCommandSender(this, target, plugin, joinResponseType, "CONSOLE"),
|
||||
myMessage.trim().substring(1)));
|
||||
} else if (joinNoticeCtcp) {
|
||||
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) {
|
||||
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 {
|
||||
plugin.logDebug("tabPacket: deprecated ");
|
||||
playerListConstructor = protocolManager.createPacketConstructor(Packets.Server.PLAYER_INFO, "", false, (int) 0);
|
||||
|
@ -326,6 +326,8 @@ channels:
|
||||
private: true
|
||||
# If true then message will be sent via ctcp. if false then normal msg
|
||||
ctcp: true
|
||||
# send a notice message (overrides ctcp)
|
||||
notice: false
|
||||
# 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.
|
||||
message: '/list'
|
||||
@ -354,6 +356,7 @@ channels:
|
||||
modes: '*'
|
||||
private: false
|
||||
ctcp: false
|
||||
notice: false
|
||||
game_command: '@chat'
|
||||
extras_commands: []
|
||||
private_listen: true
|
||||
@ -366,6 +369,7 @@ channels:
|
||||
modes: '*'
|
||||
private: false
|
||||
ctcp: false
|
||||
notice: false
|
||||
game_command: '@ochat'
|
||||
extras_commands: []
|
||||
private_listen: true
|
||||
@ -378,6 +382,7 @@ channels:
|
||||
modes: '*'
|
||||
private: false
|
||||
ctcp: false
|
||||
notice: false
|
||||
game_command: '@hchat'
|
||||
extras_commands: []
|
||||
private_listen: true
|
||||
@ -390,6 +395,7 @@ channels:
|
||||
modes: '*'
|
||||
private: true
|
||||
ctcp: false
|
||||
notice: false
|
||||
game_command: '@msg'
|
||||
extras_commands: []
|
||||
private_listen: true
|
||||
@ -402,6 +408,7 @@ channels:
|
||||
modes: '*'
|
||||
private: 'true'
|
||||
ctcp: 'false'
|
||||
notice: false
|
||||
game_command: '@r'
|
||||
private_listen: 'true'
|
||||
channel_listen: 'true'
|
||||
@ -416,6 +423,7 @@ channels:
|
||||
modes: '*'
|
||||
private: false
|
||||
ctcp: false
|
||||
notice: false
|
||||
game_command: '@list'
|
||||
extras_commands: []
|
||||
private_listen: true
|
||||
@ -428,6 +436,7 @@ channels:
|
||||
modes: '*'
|
||||
private: false
|
||||
ctcp: false
|
||||
notice: false
|
||||
game_command: '@help'
|
||||
extras_commands: []
|
||||
private_listen: true
|
||||
@ -440,6 +449,7 @@ channels:
|
||||
modes: '*'
|
||||
private: false
|
||||
ctcp: false
|
||||
notice: false
|
||||
game_command: '@uptime'
|
||||
extras_commands: []
|
||||
private_listen: true
|
||||
@ -452,6 +462,7 @@ channels:
|
||||
modes: '*'
|
||||
private: false
|
||||
ctcp: false
|
||||
notice: false
|
||||
game_command: '@versionfull'
|
||||
extras_commands: []
|
||||
private_listen: true
|
||||
@ -464,6 +475,7 @@ channels:
|
||||
modes: '*'
|
||||
private: false
|
||||
ctcp: false
|
||||
notice: false
|
||||
game_command: lag
|
||||
extras_commands: []
|
||||
private_listen: true
|
||||
@ -476,6 +488,7 @@ channels:
|
||||
modes: 'o'
|
||||
private: 'false'
|
||||
ctcp: 'false'
|
||||
notice: false
|
||||
game_command: '@list'
|
||||
extra_commands:
|
||||
- '@version'
|
||||
|
Loading…
Reference in New Issue
Block a user