mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-06-27 23:24:41 +02:00
Now we can send messages to mcMMO chat channels. (party and admin)
This commit is contained in:
parent
e7bc3f5f85
commit
c8c61949a6
|
@ -19,8 +19,6 @@ package com.cnaude.purpleirc;
|
|||
import com.cnaude.purpleirc.Events.IRCCommandEvent;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import net.minecraft.server.v1_8_R2.RemoteControlCommandListener;
|
||||
import static org.bukkit.Bukkit.getServer;
|
||||
import org.bukkit.command.CommandException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -50,12 +50,12 @@ public class GamePlayerChatListener implements Listener {
|
|||
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
|
||||
String message = event.getMessage();
|
||||
plugin.logDebug("ChatFormat [" + event.isCancelled() + "]: " + event.getFormat());
|
||||
if (message.startsWith("[[townytag]]")) {
|
||||
event.setMessage(message.replace("[[townytag]]", ""));
|
||||
plugin.logDebug("Ignoring due to townytag");
|
||||
if (message.startsWith(PurpleIRC.TOWNYTAG)) {
|
||||
event.setMessage(message.replace(PurpleIRC.TOWNYTAG, ""));
|
||||
plugin.logDebug("Ignoring due to TownyChat tag");
|
||||
return;
|
||||
}
|
||||
event.setMessage(message.replace("[[townytag]]", ""));
|
||||
event.setMessage(message.replace(PurpleIRC.TOWNYTAG, ""));
|
||||
if (event.isCancelled() && !plugin.isPluginEnabled("FactionChat") && !plugin.ignoreChatCancel) {
|
||||
plugin.logDebug("Ignore chat message due to event cancellation: " + event.getMessage());
|
||||
return;
|
||||
|
|
|
@ -39,7 +39,15 @@ public class McMMOChatListener implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void onMcMMOChatEvent(McMMOChatEvent event) {
|
||||
event.setMessage(event.getMessage().replace("[[townytag]]", ""));
|
||||
String message = event.getMessage();
|
||||
message = message.replace(PurpleIRC.TOWNYTAG, "");
|
||||
if (message.contains(PurpleIRC.PURPLETAG)) {
|
||||
message = message.replace(PurpleIRC.PURPLETAG, "");
|
||||
event.setMessage(message);
|
||||
plugin.logDebug("[onMcMMOChatEvent]: PurpleIRC tag detected. Not sending back IRC." );
|
||||
return;
|
||||
}
|
||||
|
||||
String sender = event.getSender();
|
||||
Player player = plugin.getServer().getPlayer(sender);
|
||||
plugin.logDebug("McMMOChatEvent caught: " + sender);
|
||||
|
@ -54,14 +62,22 @@ public class McMMOChatListener implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void onMcMMOAdminChatEvent(McMMOAdminChatEvent event) {
|
||||
event.setMessage(event.getMessage().replace("[[townytag]]", ""));
|
||||
String message = event.getMessage();
|
||||
message = message.replace(PurpleIRC.TOWNYTAG, "");
|
||||
if (message.contains(PurpleIRC.PURPLETAG)) {
|
||||
message = message.replace(PurpleIRC.PURPLETAG, "");
|
||||
event.setMessage(message);
|
||||
plugin.logDebug("[onMcMMOAdminChatEvent]: PurpleIRC tag detected. Not sending back IRC." );
|
||||
return;
|
||||
}
|
||||
|
||||
String sender = event.getSender();
|
||||
Player player = plugin.getServer().getPlayer(sender);
|
||||
plugin.logDebug("McMMOAdminChatEvent caught: " + sender);
|
||||
if (player != null && !sender.isEmpty()) {
|
||||
if (player.hasPermission("irc.message.gamechat")) {
|
||||
for (PurpleBot ircBot : plugin.ircBots.values()) {
|
||||
ircBot.mcMMOAdminChat(player, event.getMessage());
|
||||
ircBot.mcMMOAdminChat(player, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +85,15 @@ public class McMMOChatListener implements Listener {
|
|||
|
||||
@EventHandler
|
||||
public void onMcMMOPartyChatEvent(McMMOPartyChatEvent event) {
|
||||
event.setMessage(event.getMessage().replace("[[townytag]]", ""));
|
||||
String message = event.getMessage();
|
||||
message = message.replace(PurpleIRC.TOWNYTAG, "");
|
||||
if (message.contains(PurpleIRC.PURPLETAG)) {
|
||||
message = message.replace(PurpleIRC.PURPLETAG, "");
|
||||
event.setMessage(message);
|
||||
plugin.logDebug("[onMcMMOPartyChatEvent]: PurpleIRC tag detected. Not sending back IRC." );
|
||||
return;
|
||||
}
|
||||
|
||||
String sender = event.getSender();
|
||||
Player player = plugin.getServer().getPlayer(sender);
|
||||
String party = event.getParty();
|
||||
|
@ -80,6 +104,6 @@ public class McMMOChatListener implements Listener {
|
|||
ircBot.mcMMOPartyChat(player, party, event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,6 +52,6 @@ public class TownyChatListener implements Listener {
|
|||
plugin.tcHook.sendToIrc(ircBot, player, townyChannel, event.getMessage());
|
||||
}
|
||||
}
|
||||
event.getAsyncPlayerChatEvent().setMessage("[[townytag]]" + event.getMessage());
|
||||
event.getAsyncPlayerChatEvent().setMessage(PurpleIRC.TOWNYTAG + event.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
62
src/main/java/com/cnaude/purpleirc/Hooks/McMMOChatHook.java
Normal file
62
src/main/java/com/cnaude/purpleirc/Hooks/McMMOChatHook.java
Normal file
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* 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.Hooks;
|
||||
|
||||
import com.cnaude.purpleirc.PurpleIRC;
|
||||
import com.gmail.nossr50.api.ChatAPI;
|
||||
import com.gmail.nossr50.api.PartyAPI;
|
||||
import com.gmail.nossr50.datatypes.party.Party;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author cnaude
|
||||
*/
|
||||
public class McMMOChatHook {
|
||||
|
||||
private final PurpleIRC plugin;
|
||||
private final Plugin mcMMOPlugin;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param plugin
|
||||
*/
|
||||
public McMMOChatHook(PurpleIRC plugin) {
|
||||
this.plugin = plugin;
|
||||
this.mcMMOPlugin = plugin.getServer().getPluginManager().getPlugin("mcMMO");
|
||||
}
|
||||
|
||||
public void sendAdminMessage(String sender, String message) {
|
||||
if (mcMMOPlugin != null) {
|
||||
plugin.logDebug("[mcMMOChatHook:sendAdminMessage]: " + message);
|
||||
ChatAPI.sendAdminChat(mcMMOPlugin, sender, PurpleIRC.PURPLETAG + message);
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPartyMessage(String sender, String party, String message) {
|
||||
if (mcMMOPlugin != null) {
|
||||
for (Party p : PartyAPI.getParties()) {
|
||||
if (p.getName().equalsIgnoreCase(party)) {
|
||||
plugin.logDebug("[mcMMOChatHook:sendPartyMessage]: " + party + " : " + message);
|
||||
ChatAPI.sendPartyChat(mcMMOPlugin, sender, party, PurpleIRC.PURPLETAG + message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -989,10 +989,10 @@ public final class PurpleBot {
|
|||
|| worldList.get(channelName).contains(worldName)) {
|
||||
validWorld = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
plugin.logDebug("[isPlayerInValidWorld] [p: " + player.getName() + "] [w: " + worldName + "] [b: " + validWorld + "]");
|
||||
return validWorld;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called from normal game chat listener
|
||||
|
@ -1010,45 +1010,45 @@ public final class PurpleBot {
|
|||
}
|
||||
for (String channelName : botChannels) {
|
||||
if (isPlayerInValidWorld(player, channelName)) {
|
||||
if (plugin.fcHook != null) {
|
||||
String playerChatMode;
|
||||
String playerFactionName;
|
||||
try {
|
||||
playerChatMode = plugin.fcHook.getChatMode(player);
|
||||
} catch (IllegalAccessError ex) {
|
||||
plugin.logDebug("FC Error: " + ex.getMessage());
|
||||
playerChatMode = "public";
|
||||
}
|
||||
try {
|
||||
playerFactionName = plugin.fcHook.getFactionName(player);
|
||||
} catch (IllegalAccessError ex) {
|
||||
plugin.logDebug("FC Error: " + ex.getMessage());
|
||||
playerFactionName = "unknown";
|
||||
}
|
||||
if (plugin.fcHook != null) {
|
||||
String playerChatMode;
|
||||
String playerFactionName;
|
||||
try {
|
||||
playerChatMode = plugin.fcHook.getChatMode(player);
|
||||
} catch (IllegalAccessError ex) {
|
||||
plugin.logDebug("FC Error: " + ex.getMessage());
|
||||
playerChatMode = "public";
|
||||
}
|
||||
try {
|
||||
playerFactionName = plugin.fcHook.getFactionName(player);
|
||||
} catch (IllegalAccessError ex) {
|
||||
plugin.logDebug("FC Error: " + ex.getMessage());
|
||||
playerFactionName = "unknown";
|
||||
}
|
||||
|
||||
String chatName = "faction-" + playerChatMode.toLowerCase() + "-chat";
|
||||
plugin.logDebug("Faction [Player: " + player.getName()
|
||||
+ "] [Tag: " + playerFactionName + "] [Mode: "
|
||||
+ playerChatMode + "]");
|
||||
if (enabledMessages.get(channelName)
|
||||
.contains(chatName)) {
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.chatFactionTokenizer(player, botNick, message,
|
||||
playerFactionName, playerChatMode));
|
||||
String chatName = "faction-" + playerChatMode.toLowerCase() + "-chat";
|
||||
plugin.logDebug("Faction [Player: " + player.getName()
|
||||
+ "] [Tag: " + playerFactionName + "] [Mode: "
|
||||
+ playerChatMode + "]");
|
||||
if (enabledMessages.get(channelName)
|
||||
.contains(chatName)) {
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.chatFactionTokenizer(player, botNick, message,
|
||||
playerFactionName, playerChatMode));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName() + " is in chat mode \""
|
||||
+ playerChatMode + "\" but \"" + chatName + "\" is disabled.");
|
||||
}
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName() + " is in chat mode \""
|
||||
+ playerChatMode + "\" but \"" + chatName + "\" is disabled.");
|
||||
plugin.logDebug("No Factions");
|
||||
}
|
||||
if (isMessageEnabled(channelName, TemplateName.GAME_CHAT)) {
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(botNick, TemplateName.GAME_CHAT), message));
|
||||
}
|
||||
} else {
|
||||
plugin.logDebug("No Factions");
|
||||
}
|
||||
if (isMessageEnabled(channelName, TemplateName.GAME_CHAT)) {
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(botNick, TemplateName.GAME_CHAT), message));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sendFloodWarning(Player player) {
|
||||
String message = plugin.getMsgTemplate(
|
||||
|
@ -1077,22 +1077,22 @@ public final class PurpleBot {
|
|||
}
|
||||
for (String channelName : botChannels) {
|
||||
if (isPlayerInValidWorld(player, channelName)) {
|
||||
String hChannel = chatter.getActiveChannel().getName();
|
||||
String hNick = chatter.getActiveChannel().getNick();
|
||||
String hColor = chatColor.toString();
|
||||
plugin.logDebug("HC Channel: " + hChannel);
|
||||
if (isMessageEnabled(channelName, "hero-" + hChannel + "-chat")
|
||||
|| isMessageEnabled(channelName, TemplateName.HERO_CHAT)) {
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.chatHeroTokenizer(player, message, hColor, hChannel,
|
||||
hNick, plugin.getHeroChatChannelTemplate(botNick, hChannel)));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName() + " is in \""
|
||||
+ hChannel + "\" but hero-" + hChannel + "-chat is disabled.");
|
||||
String hChannel = chatter.getActiveChannel().getName();
|
||||
String hNick = chatter.getActiveChannel().getNick();
|
||||
String hColor = chatColor.toString();
|
||||
plugin.logDebug("HC Channel: " + hChannel);
|
||||
if (isMessageEnabled(channelName, "hero-" + hChannel + "-chat")
|
||||
|| isMessageEnabled(channelName, TemplateName.HERO_CHAT)) {
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.chatHeroTokenizer(player, message, hColor, hChannel,
|
||||
hNick, plugin.getHeroChatChannelTemplate(botNick, hChannel)));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName() + " is in \""
|
||||
+ hChannel + "\" but hero-" + hChannel + "-chat is disabled.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mcMMOAdminChat(Player player, String message) {
|
||||
if (!this.isConnected()) {
|
||||
|
@ -1104,18 +1104,18 @@ public final class PurpleBot {
|
|||
}
|
||||
for (String channelName : botChannels) {
|
||||
if (isPlayerInValidWorld(player, channelName)) {
|
||||
if (isMessageEnabled(channelName, TemplateName.MCMMO_ADMIN_CHAT)) {
|
||||
plugin.logDebug("Sending message because " + TemplateName.MCMMO_ADMIN_CHAT + " is enabled.");
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.mcMMOChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
||||
botNick, TemplateName.MCMMO_ADMIN_CHAT), message));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName()
|
||||
+ " is in mcMMO AdminChat but " + TemplateName.MCMMO_ADMIN_CHAT + " is disabled.");
|
||||
if (isMessageEnabled(channelName, TemplateName.MCMMO_ADMIN_CHAT)) {
|
||||
plugin.logDebug("Sending message because " + TemplateName.MCMMO_ADMIN_CHAT + " is enabled.");
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.mcMMOChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
||||
botNick, TemplateName.MCMMO_ADMIN_CHAT), message));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName()
|
||||
+ " is in mcMMO AdminChat but " + TemplateName.MCMMO_ADMIN_CHAT + " is disabled.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mcMMOPartyChat(Player player, String partyName, String message) {
|
||||
if (!this.isConnected()) {
|
||||
|
@ -1127,18 +1127,18 @@ public final class PurpleBot {
|
|||
}
|
||||
for (String channelName : botChannels) {
|
||||
if (isPlayerInValidWorld(player, channelName)) {
|
||||
if (isMessageEnabled(channelName, TemplateName.MCMMO_PARTY_CHAT)) {
|
||||
plugin.logDebug("Sending message because " + TemplateName.MCMMO_PARTY_CHAT + " is enabled.");
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.mcMMOPartyChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
||||
botNick, TemplateName.MCMMO_PARTY_CHAT), message, partyName));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName()
|
||||
+ " is in mcMMO PartyChat but " + TemplateName.MCMMO_PARTY_CHAT + " is disabled.");
|
||||
if (isMessageEnabled(channelName, TemplateName.MCMMO_PARTY_CHAT)) {
|
||||
plugin.logDebug("Sending message because " + TemplateName.MCMMO_PARTY_CHAT + " is enabled.");
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.mcMMOPartyChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
||||
botNick, TemplateName.MCMMO_PARTY_CHAT), message, partyName));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName()
|
||||
+ " is in mcMMO PartyChat but " + TemplateName.MCMMO_PARTY_CHAT + " is disabled.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void mcMMOChat(Player player, String message) {
|
||||
if (!this.isConnected()) {
|
||||
|
@ -1150,18 +1150,18 @@ public final class PurpleBot {
|
|||
}
|
||||
for (String channelName : botChannels) {
|
||||
if (isPlayerInValidWorld(player, channelName)) {
|
||||
if (isMessageEnabled(channelName, TemplateName.MCMMO_CHAT)) {
|
||||
plugin.logDebug("Sending message because " + TemplateName.MCMMO_CHAT + " is enabled.");
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.mcMMOChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
||||
botNick, TemplateName.MCMMO_CHAT), message));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName()
|
||||
+ " is in mcMMO Chat but " + TemplateName.MCMMO_CHAT + " is disabled.");
|
||||
if (isMessageEnabled(channelName, TemplateName.MCMMO_CHAT)) {
|
||||
plugin.logDebug("Sending message because " + TemplateName.MCMMO_CHAT + " is enabled.");
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.mcMMOChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
||||
botNick, TemplateName.MCMMO_CHAT), message));
|
||||
} else {
|
||||
plugin.logDebug("Player " + player.getName()
|
||||
+ " is in mcMMO Chat but " + TemplateName.MCMMO_CHAT + " is disabled.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void heroAction(Chatter chatter, ChatColor chatColor, String message) {
|
||||
if (!this.isConnected()) {
|
||||
|
@ -1472,11 +1472,11 @@ public final class PurpleBot {
|
|||
return;
|
||||
}
|
||||
for (String channelName : botChannels) {
|
||||
if (hideJoinWhenVanished.get(channelName)) {
|
||||
if (plugin.vanishHook.isVanished(player)) {
|
||||
continue;
|
||||
}
|
||||
if (hideJoinWhenVanished.get(channelName)) {
|
||||
if (plugin.vanishHook.isVanished(player)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (isMessageEnabled(channelName, TemplateName.GAME_JOIN)
|
||||
&& isPlayerInValidWorld(player, channelName)) {
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
|
@ -1496,11 +1496,11 @@ public final class PurpleBot {
|
|||
return;
|
||||
}
|
||||
for (String channelName : botChannels) {
|
||||
if (hideQuitWhenVanished.get(channelName)) {
|
||||
if (plugin.vanishHook.isVanished(player)) {
|
||||
continue;
|
||||
}
|
||||
if (hideQuitWhenVanished.get(channelName)) {
|
||||
if (plugin.vanishHook.isVanished(player)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (isMessageEnabled(channelName, TemplateName.GAME_QUIT)
|
||||
&& isPlayerInValidWorld(player, channelName)) {
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
|
@ -1644,13 +1644,13 @@ public final class PurpleBot {
|
|||
for (String channelName : botChannels) {
|
||||
if (isMessageEnabled(channelName, templateName)) {
|
||||
if (isPlayerInValidWorld(player, channelName)) {
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
||||
botNick, templateName), message));
|
||||
asyncIRCMessage(channelName, plugin.tokenizer
|
||||
.gameChatToIRCTokenizer(player, plugin.getMsgTemplate(
|
||||
botNick, templateName), message));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -2299,7 +2299,7 @@ public final class PurpleBot {
|
|||
return message;
|
||||
}
|
||||
|
||||
// Broadcast chat messages from IRC
|
||||
// Broadcast chat messages from IRC to the game
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
|
@ -2366,6 +2366,42 @@ public final class PurpleBot {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Send messages to mcMMO if enabled
|
||||
*/
|
||||
if (plugin.mcMMOChatHook != null) {
|
||||
/*
|
||||
Send to mcMMMO admin channel if enabled
|
||||
*/
|
||||
if (isMessageEnabled(myChannel, TemplateName.IRC_MCMMO_ADMIN_CHAT)) {
|
||||
String tmpl = plugin.getMsgTemplate(botNick, TemplateName.IRC_MCMMO_ADMIN_CHAT);
|
||||
plugin.logDebug("broadcastChat [mcMMO:admin]: " + message);
|
||||
String rawMcMMOMessage = filterMessage(
|
||||
plugin.tokenizer.ircChatToGameTokenizer(this, user, channel, tmpl, message), myChannel);
|
||||
plugin.mcMMOChatHook.sendAdminMessage(user.getNick(), rawMcMMOMessage);
|
||||
messageSent = true;
|
||||
|
||||
}
|
||||
/*
|
||||
Send to specific mcMMMO party channel if enabled
|
||||
*/
|
||||
for (String em : getEnabledMessages(channel.getName())) {
|
||||
if (em.startsWith("irc-mcmmo-party-") && em.endsWith("-chat")) {
|
||||
if (isMessageEnabled(myChannel, em)) {
|
||||
String party = em.replace("irc-mcmmo-party-", "").replace("-chat", "");
|
||||
if (!party.isEmpty()) {
|
||||
String tmpl = plugin.getMsgTemplate(botNick, TemplateName.IRC_MCMMO_PARTY_CHAT);
|
||||
plugin.logDebug("broadcastChat [mcMMO:party]: " + party + " : " + message);
|
||||
String rawMcMMOMessage = filterMessage(
|
||||
plugin.tokenizer.ircChatToGameTokenizer(this, user, channel, tmpl, message), myChannel);
|
||||
plugin.mcMMOChatHook.sendPartyMessage(user.getNick(), party, rawMcMMOMessage);
|
||||
messageSent = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Send messages to players if enabled
|
||||
*/
|
||||
|
@ -2767,6 +2803,18 @@ public final class PurpleBot {
|
|||
return isEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param channelName
|
||||
* @return
|
||||
*/
|
||||
public Collection<String> getEnabledMessages(String channelName) {
|
||||
if (enabledMessages.containsKey(channelName)) {
|
||||
return enabledMessages.get(channelName);
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param channel
|
||||
|
|
|
@ -44,6 +44,7 @@ import com.cnaude.purpleirc.Hooks.CommandBookHook;
|
|||
import com.cnaude.purpleirc.Hooks.DynmapHook;
|
||||
import com.cnaude.purpleirc.Hooks.FactionChatHook;
|
||||
import com.cnaude.purpleirc.Hooks.JobsHook;
|
||||
import com.cnaude.purpleirc.Hooks.McMMOChatHook;
|
||||
import com.cnaude.purpleirc.Hooks.ReportRTSHook;
|
||||
import com.cnaude.purpleirc.Hooks.ShortifyHook;
|
||||
import com.cnaude.purpleirc.Hooks.SuperVanishHook;
|
||||
|
@ -174,6 +175,7 @@ public class PurpleIRC extends JavaPlugin {
|
|||
public ShortifyHook shortifyHook;
|
||||
public ReportRTSHook reportRTSHook;
|
||||
public CommandBookHook commandBookHook;
|
||||
public McMMOChatHook mcMMOChatHook;
|
||||
public NetPackets netPackets;
|
||||
public CommandHandlers commandHandlers;
|
||||
public PurpleTabCompleter ircTabCompleter;
|
||||
|
@ -212,6 +214,8 @@ public class PurpleIRC extends JavaPlugin {
|
|||
final String PL_TITANCHAT = "TitanChat";
|
||||
final String PL_HEROCHAT = "Herochat";
|
||||
List<String> hookList = new ArrayList<>();
|
||||
public static final String PURPLETAG = "UHVycGxlSVJDCg==";
|
||||
public static final String TOWNYTAG = "VG93bnlDaGF0Cg==";
|
||||
|
||||
public PurpleIRC() {
|
||||
this.MAINCONFIG = "MAIN-CONFIG";
|
||||
|
@ -1424,6 +1428,7 @@ public class PurpleIRC extends JavaPlugin {
|
|||
if (isPluginEnabled(PL_MCMMO)) {
|
||||
hookList.add(hookFormat(PL_MCMMO, true));
|
||||
getServer().getPluginManager().registerEvents(new McMMOChatListener(this), this);
|
||||
mcMMOChatHook = new McMMOChatHook(this);
|
||||
} else {
|
||||
hookList.add(hookFormat(PL_MCMMO, false));
|
||||
}
|
||||
|
|
|
@ -47,6 +47,9 @@ public class TemplateName {
|
|||
public final static String MCMMO_ADMIN_CHAT = "mcmmo-admin-chat";
|
||||
public final static String MCMMO_PARTY_CHAT = "mcmmo-party-chat";
|
||||
public final static String MCMMO_CHAT = "mcmmo-chat";
|
||||
|
||||
public final static String IRC_MCMMO_ADMIN_CHAT = "irc-mcmmo-admin-chat";
|
||||
public final static String IRC_MCMMO_PARTY_CHAT = "irc-mcmmo-party-chat";
|
||||
|
||||
public final static String HERO_ACTION = "hero-action";
|
||||
public final static String HERO_CHAT = "hero-chat";
|
||||
|
|
|
@ -164,8 +164,11 @@ channels:
|
|||
- irc-action-dynmap-web-chat
|
||||
# mcMMO messages sent to IRC
|
||||
- mcmmo-admin-chat
|
||||
- mcmmo-party-chat
|
||||
- mcmmo-party-chat
|
||||
- mcmmo-chat
|
||||
# mcMMO messages sent from IRC. Replace [PARTY] with destination mcMMO party
|
||||
- irc-mcmmo-admin-chat
|
||||
- irc-mcmmo-party-[PARTY]-chat
|
||||
# FactionChat messages sent to IRC
|
||||
- faction-public-chat
|
||||
- faction-ally-chat
|
||||
|
|
|
@ -14,8 +14,8 @@ enable-ident-server: false
|
|||
channel-check-interval: 100
|
||||
# Chat messages support standard Bukkit color codes using '&#'. See http://minecraft.gamepedia.com/Formatting_codes
|
||||
# The following macro tokens are also supported.
|
||||
# %WORLD%
|
||||
# %NAME%
|
||||
# %WORLD%
|
||||
# %NAME%
|
||||
# %HOST% - Host of player or IRC user
|
||||
# %SERVER% - Server of IRC user
|
||||
# %AWAY% - IRC user away message
|
||||
|
@ -26,7 +26,7 @@ channel-check-interval: 100
|
|||
# %CHANNELPREFIX% - Custom prefix per channel (see prefix option in SampleBot.yml)
|
||||
# %DISPLAYNAME% - Player's custom name
|
||||
# %PLAYERIP% - IP address of a player
|
||||
# %CHANNEL%
|
||||
# %CHANNEL%
|
||||
# %MESSAGE%
|
||||
# %KICKER% - IRC kicker name
|
||||
# %TOPIC%
|
||||
|
@ -76,20 +76,20 @@ channel-check-interval: 100
|
|||
# prism-custom:
|
||||
# %ACTION%
|
||||
# %MESSAGE%
|
||||
# %PLUGIN%
|
||||
# %PLUGIN%
|
||||
message-format:
|
||||
# Message templates for game to IRC messages
|
||||
console-chat: '[&dServer&r] %MESSAGE%'
|
||||
# Message templates for game to IRC messages
|
||||
console-chat: '[&dServer&r] %MESSAGE%'
|
||||
game-achievement: '[&2%WORLD%&r] %NAME% has just earned the achievement [%MESSAGE%]'
|
||||
game-mode: '[&2%WORLD%&r] %NAME% has changed game mode: [%MESSAGE%]'
|
||||
game-action: '[&2%WORLD%&r]***%NAME% %MESSAGE%'
|
||||
game-pchat: '[&2%WORLD%] <%NAME%> %MESSAGE%'
|
||||
# death-messages - http://dev.bukkit.org/bukkit-plugins/death-messages
|
||||
death-messages: '[&2%WORLD%&r]%MESSAGE%'
|
||||
death-messages: '[&2%WORLD%&r]%MESSAGE%'
|
||||
# Notification to player when sending a private message to an IRC user
|
||||
game-pchat-response: ' &6-> &7%TARGET%: %MESSAGE%'
|
||||
game-chat: '[&2%WORLD%&r] <%NAME%> %MESSAGE%'
|
||||
game-death: '[&2%WORLD%&r] %MESSAGE%'
|
||||
game-chat: '[&2%WORLD%&r] <%NAME%> %MESSAGE%'
|
||||
game-death: '[&2%WORLD%&r] %MESSAGE%'
|
||||
game-kick: '[&2%WORLD%&r] %MESSAGE%: %REASON%'
|
||||
game-join: '[&2%WORLD%&r] %NAME% joined the game.'
|
||||
game-quit: '[&2%WORLD%&r] %NAME% left the game.'
|
||||
|
@ -97,28 +97,28 @@ message-format:
|
|||
fake-quit: '[&2%WORLD%&r] %NAME% left the game.'
|
||||
game-command: '[&2%WORLD%&r] Command detected by %NAME%: %COMMAND% %PARAMS%'
|
||||
# Message template for "/irc send" to IRC message
|
||||
game-send: '[&2%WORLD%&r]<%NAME%> %MESSAGE%'
|
||||
game-send: '[&2%WORLD%&r]<%NAME%> %MESSAGE%'
|
||||
# Essentials messages
|
||||
ess-player-afk: '[&2%WORLD%&r] %NAME% is now AFK'
|
||||
ess-player-not-afk: '[&2%WORLD%&r] %NAME% is no longer AFK'
|
||||
ess-player-afk: '[&2%WORLD%&r] %NAME% is now AFK'
|
||||
ess-player-not-afk: '[&2%WORLD%&r] %NAME% is no longer AFK'
|
||||
ess-helpop: '&4[HelpOp] %DISPLAYNAME%&r: %MESSAGE%'
|
||||
irc-ess-helpop: '&4[HelpOp] %DISPLAYNAME%&r: %MESSAGE%'
|
||||
# Message templates for IRC to game messages
|
||||
irc-action: '[&4IRC&r] ***%NAME% %MESSAGE%'
|
||||
irc-chat: '[&4IRC&r]<%NAME%> %MESSAGE%'
|
||||
irc-chat: '[&4IRC&r]<%NAME%> %MESSAGE%'
|
||||
# Response message when using @chat or @ochat
|
||||
irc-chat-response: ' &6-> &7Minecraft: %MESSAGE%'
|
||||
irc-pchat: '&dPrivate message: [&4IRC&r]<%NAME%> %MESSAGE%'
|
||||
irc-pchat: '&dPrivate message: [&4IRC&r]<%NAME%> %MESSAGE%'
|
||||
# Notification to user when sending a private message to a player
|
||||
irc-pchat-response: ' &6-> &7%TARGET%: %MESSAGE%'
|
||||
# Notification to user when sending a message to a specific hero channel
|
||||
irc-hchat-response: ' &6-> &7%TARGET%: %MESSAGE%'
|
||||
irc-join: '[&4IRC&r] %NAME% has joined %CHANNEL%.'
|
||||
irc-kick: '[&4IRC&r] %NAME% was kicked from %CHANNEL% by %KICKER%. (Reason- %REASON%)'
|
||||
irc-part: '[&4IRC&r] %NAME% has left %CHANNEL%.'
|
||||
irc-quit: '[&4IRC&r] %NAME% has left %CHANNEL%. (Reason: %REASON%)'
|
||||
irc-topic: '[&4IRC&r] Topic changed by %NAME%: %TOPIC%.'
|
||||
irc-nickchange: '[&4IRC&r] %OLDNICK% is now known as %NEWNICK%.'
|
||||
irc-part: '[&4IRC&r] %NAME% has left %CHANNEL%.'
|
||||
irc-quit: '[&4IRC&r] %NAME% has left %CHANNEL%. (Reason: %REASON%)'
|
||||
irc-topic: '[&4IRC&r] Topic changed by %NAME%: %TOPIC%.'
|
||||
irc-nickchange: '[&4IRC&r] %OLDNICK% is now known as %NEWNICK%.'
|
||||
irc-mode: '[&4IRC&r] %NAME% %MODE% on %CHANNEL%'
|
||||
irc-console-chat: '&f[&5IRC&f]&r<%NAME%> %MESSAGE%'
|
||||
irc-notice: '[&4IRC&r] [notice(%CHANNEL%)] %NOTICE% '
|
||||
|
@ -129,26 +129,29 @@ message-format:
|
|||
# AdminPrivateChat message from IRC to game
|
||||
irc-a-chat: '[AdminChat] [&4IRC&r] %MESSAGE%'
|
||||
# Message template for Clevernotch bot to IRC messages
|
||||
clever-send: '[&4BOT]<%NAME%> %MESSAGE%'
|
||||
clever-send: '[&4BOT]<%NAME%> %MESSAGE%'
|
||||
# Message templates for mcMMO to IRC messages
|
||||
mcmmo-admin-chat: '[admin:%WORLD%]<%NAME%> %MESSAGE%'
|
||||
mcmmo-admin-chat: '[admin:%WORLD%]<%NAME%> %MESSAGE%'
|
||||
mcmmo-party-chat: '[party:%PARTY%]<%NAME%> %MESSAGE%'
|
||||
mcmmo-chat: '[mcMMO]<%NAME%> %MESSAGE%'
|
||||
# Message templates for IRC to mcMMO
|
||||
irc-mcmmo-admin-chat: '[&4IRC&r]<%NAME%> %MESSAGE%'
|
||||
irc-mcmmo-party-chat: '[&4IRC&r]<%NAME%> %MESSAGE%'
|
||||
# Message templates for FactionChat to IRC messages
|
||||
faction-public-chat: '[%FACTIONMODE%&r][%FACTIONTAG%]<%NAME%> %MESSAGE%'
|
||||
faction-ally-chat: '[%FACTIONMODE%&r][%FACTIONTAG%]<%NAME%> %MESSAGE%'
|
||||
faction-enemy-chat: '[%FACTIONMODE%&r][%FACTIONTAG%]<%NAME%> %MESSAGE%'
|
||||
faction-public-chat: '[%FACTIONMODE%&r][%FACTIONTAG%]<%NAME%> %MESSAGE%'
|
||||
faction-ally-chat: '[%FACTIONMODE%&r][%FACTIONTAG%]<%NAME%> %MESSAGE%'
|
||||
faction-enemy-chat: '[%FACTIONMODE%&r][%FACTIONTAG%]<%NAME%> %MESSAGE%'
|
||||
# Message template for Herochat to IRC messages
|
||||
hero-chat: '[%CHANNEL%]<%NAME%> %MESSAGE%'
|
||||
hero-action: '[&2%CHANNEL%&r]***%NAME% %MESSAGE%'
|
||||
# Message templates for IRC to Herochat messages
|
||||
irc-hero-action: '[&3IRC&r] ***%NAME% %MESSAGE%'
|
||||
irc-hero-chat: '[&3IRC&r]<%NAME%> %MESSAGE%'
|
||||
irc-hero-chat: '[&3IRC&r]<%NAME%> %MESSAGE%'
|
||||
irc-hero-join: '[&3IRC&r] %NAME% has joined %CHANNEL%.'
|
||||
irc-hero-kick: '[&3IRC&r] %NAME% was kicked from %CHANNEL% by %KICKER%. (Reason- %REASON%)'
|
||||
irc-hero-part: '[&3IRC&r] %NAME% has left %CHANNEL%.'
|
||||
irc-hero-quit: '[&3IRC&r] %NAME% has left %CHANNEL%.'
|
||||
irc-hero-topic: '[&3IRC&r] Topic changed by %NAME%: %TOPIC%.'
|
||||
irc-hero-part: '[&3IRC&r] %NAME% has left %CHANNEL%.'
|
||||
irc-hero-quit: '[&3IRC&r] %NAME% has left %CHANNEL%.'
|
||||
irc-hero-topic: '[&3IRC&r] Topic changed by %NAME%: %TOPIC%.'
|
||||
# Message template for TitanChat to IRC messages
|
||||
titan-chat: '[%CHANNEL%]<%NAME%> %MESSAGE%'
|
||||
# Message templates for IRC to TitanChat messages
|
||||
|
@ -213,7 +216,7 @@ message-format:
|
|||
default-group-suffix: ''
|
||||
default-group-prefix: ''
|
||||
default-player-world: 'world'
|
||||
default-player-group: ''
|
||||
default-player-group: ''
|
||||
# Flood control
|
||||
game-flood-warning: '&3Message not sent to IRC due to spamming. &rCooldown: %COOLDOWN%s'
|
||||
irc-flood-warning: '&3Message not sent to game due to spamming. &rCooldown: %COOLDOWN%s'
|
||||
|
@ -266,16 +269,16 @@ irc-color-map:
|
|||
UNDERLINE: UNDERLINE
|
||||
YELLOW: YELLOW
|
||||
WHITE: WHITE
|
||||
RESET: NORMAL
|
||||
RESET: NORMAL
|
||||
# IRC to game color map: IRC Color Code => Game Color Code
|
||||
game-color-map:
|
||||
BLACK: BLACK
|
||||
BLUE: BLUE
|
||||
BLUE: BLUE
|
||||
BOLD: BOLD
|
||||
BROWN: GRAY
|
||||
CYAN: AQUA
|
||||
CYAN: AQUA
|
||||
DARK_BLUE: DARK_BLUE
|
||||
DARK_GRAY: DARK_GRAY
|
||||
DARK_GRAY: DARK_GRAY
|
||||
DARK_GREEN: DARK_GREEN
|
||||
GREEN: GREEN
|
||||
LIGHT_GRAY: GRAY
|
||||
|
|
Loading…
Reference in New Issue
Block a user