2015-01-01 20:38:43 +01:00
|
|
|
/*
|
|
|
|
* 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.Utilities;
|
|
|
|
|
2015-10-22 16:23:30 +02:00
|
|
|
import com.cnaude.purpleirc.PlayerList;
|
2015-01-01 20:38:43 +01:00
|
|
|
import com.cnaude.purpleirc.PurpleBot;
|
|
|
|
import com.cnaude.purpleirc.PurpleIRC;
|
2015-06-06 21:33:26 +02:00
|
|
|
import com.cnaude.purpleirc.TemplateName;
|
2016-05-30 19:50:09 +02:00
|
|
|
import com.dthielke.herochat.ChannelManager;
|
2015-01-01 20:38:43 +01:00
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
|
|
|
import com.nyancraft.reportrts.data.Ticket;
|
|
|
|
import com.palmergames.bukkit.TownyChat.channels.Channel;
|
2015-12-21 15:38:40 +01:00
|
|
|
import java.util.UUID;
|
|
|
|
import org.bukkit.Bukkit;
|
2015-01-01 20:38:43 +01:00
|
|
|
import org.bukkit.ChatColor;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.pircbotx.User;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Main class containing all message template token expanding methods
|
|
|
|
*
|
2015-11-23 00:01:58 +01:00
|
|
|
* @author Chris Naude
|
2015-01-01 20:38:43 +01:00
|
|
|
*/
|
|
|
|
public class ChatTokenizer {
|
|
|
|
|
|
|
|
PurpleIRC plugin;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Class initializer
|
|
|
|
*
|
2015-11-23 00:01:58 +01:00
|
|
|
* @param plugin the PurpleIRC plugin
|
2015-01-01 20:38:43 +01:00
|
|
|
*/
|
|
|
|
public ChatTokenizer(PurpleIRC plugin) {
|
|
|
|
this.plugin = plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IRC to game chat tokenizer without a message
|
|
|
|
*
|
|
|
|
* @param ircBot
|
|
|
|
* @param user
|
|
|
|
* @param channel
|
|
|
|
* @param template
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String chatIRCTokenizer(PurpleBot ircBot, User user, org.pircbotx.Channel channel, String template) {
|
2015-04-22 07:00:12 +02:00
|
|
|
return plugin.colorConverter.ircColorsToGame(
|
|
|
|
ircUserTokenizer(template, user, ircBot)
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%NICKPREFIX%", ircBot.getNickPrefix(user, channel))
|
2015-04-22 07:00:12 +02:00
|
|
|
.replace("%CHANNELPREFIX%", ircBot.getChannelPrefix(channel))
|
|
|
|
.replace("%CHANNEL%", channel.getName())
|
|
|
|
);
|
2015-01-01 20:38:43 +01:00
|
|
|
}
|
|
|
|
|
2015-06-29 01:39:32 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param template
|
|
|
|
* @param user
|
|
|
|
* @param ircBot
|
|
|
|
* @return
|
|
|
|
*/
|
2015-02-28 04:00:00 +01:00
|
|
|
public String ircUserTokenizer(String template, User user, PurpleBot ircBot) {
|
2015-01-01 20:38:43 +01:00
|
|
|
String host = user.getHostmask();
|
|
|
|
String server = user.getServer();
|
|
|
|
String away = user.getAwayMessage();
|
|
|
|
String ircNick = user.getNick();
|
2015-02-28 04:00:00 +01:00
|
|
|
String customPrefix = ircBot.defaultCustomPrefix;
|
2015-01-01 20:38:43 +01:00
|
|
|
if (host == null) {
|
|
|
|
host = "";
|
|
|
|
}
|
|
|
|
if (server == null) {
|
|
|
|
server = "";
|
|
|
|
}
|
|
|
|
if (away == null) {
|
|
|
|
away = "";
|
|
|
|
}
|
2015-02-28 18:19:51 +01:00
|
|
|
plugin.logDebug("customPrefix before: " + customPrefix);
|
2015-02-28 04:00:00 +01:00
|
|
|
if (!ircBot.userPrefixes.isEmpty()) {
|
|
|
|
for (String key : ircBot.userPrefixes.keySet()) {
|
2015-03-02 03:09:38 +01:00
|
|
|
if (key.equalsIgnoreCase(user.getNick()) || ircBot.checkUserMask(user, key)) {
|
2015-02-28 04:00:00 +01:00
|
|
|
customPrefix = ircBot.userPrefixes.get(key);
|
|
|
|
break;
|
2015-03-16 18:32:15 +01:00
|
|
|
}
|
2015-02-28 04:00:00 +01:00
|
|
|
}
|
|
|
|
}
|
2015-02-28 18:19:51 +01:00
|
|
|
plugin.logDebug("customPrefix after: " + customPrefix);
|
2015-01-01 20:38:43 +01:00
|
|
|
return template.replace("%HOST%", host)
|
2015-02-28 04:00:00 +01:00
|
|
|
.replace("%CUSTOMPREFIX%", customPrefix)
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%NAME%", ircNick)
|
|
|
|
.replace("%SERVER%", server)
|
|
|
|
.replace("%AWAY%", away);
|
|
|
|
}
|
|
|
|
|
2015-06-29 01:39:32 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param template
|
|
|
|
* @param recipient
|
|
|
|
* @param kicker
|
|
|
|
* @param ircBot
|
|
|
|
* @return
|
|
|
|
*/
|
2015-02-28 04:00:00 +01:00
|
|
|
public String ircUserTokenizer(String template, User recipient, User kicker, PurpleBot ircBot) {
|
2015-01-01 20:38:43 +01:00
|
|
|
String host = kicker.getHostmask();
|
|
|
|
String server = kicker.getServer();
|
|
|
|
String away = kicker.getAwayMessage();
|
|
|
|
String ircNick = kicker.getNick();
|
|
|
|
if (host == null) {
|
|
|
|
host = "";
|
|
|
|
}
|
|
|
|
if (server == null) {
|
|
|
|
server = "";
|
|
|
|
}
|
|
|
|
if (away == null) {
|
|
|
|
away = "";
|
|
|
|
}
|
2015-02-28 04:00:00 +01:00
|
|
|
return ircUserTokenizer(template, recipient, ircBot)
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%KICKERHOST%", host)
|
|
|
|
.replace("%KICKER%", ircNick)
|
|
|
|
.replace("%KICKERSERVER%", server)
|
|
|
|
.replace("%KICKERAWAY%", away);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IRC to Hero chat tokenizer without a message
|
|
|
|
*
|
|
|
|
* @param ircBot
|
|
|
|
* @param user
|
|
|
|
* @param channel
|
|
|
|
* @param template
|
|
|
|
* @param channelManager
|
|
|
|
* @param hChannel
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String ircChatToHeroChatTokenizer(PurpleBot ircBot, User user, org.pircbotx.Channel channel, String template, ChannelManager channelManager, String hChannel) {
|
|
|
|
String ircNick = user.getNick();
|
|
|
|
String tmpl;
|
|
|
|
Player player = this.getPlayer(ircNick);
|
|
|
|
if (player != null) {
|
|
|
|
plugin.logDebug("ircChatToHeroChatTokenizer: player not null ");
|
|
|
|
tmpl = playerTokenizer(player, template);
|
|
|
|
} else {
|
|
|
|
tmpl = playerTokenizer(ircNick, template);
|
|
|
|
}
|
2015-02-28 04:00:00 +01:00
|
|
|
return plugin.colorConverter.ircColorsToGame(ircUserTokenizer(tmpl, user, ircBot)
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%HEROCHANNEL%", hChannel)
|
|
|
|
.replace("%HERONICK%", channelManager.getChannel(hChannel).getNick())
|
|
|
|
.replace("%HEROCOLOR%", channelManager.getChannel(hChannel).getColor().toString())
|
|
|
|
.replace("%NICKPREFIX%", ircBot.getNickPrefix(user, channel))
|
2015-04-22 07:00:12 +02:00
|
|
|
.replace("%CHANNELPREFIX%", ircBot.getChannelPrefix(channel))
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%CHANNEL%", channel.getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Normal IRC to game chat tokenizer
|
|
|
|
*
|
|
|
|
* @param ircBot
|
|
|
|
* @param user
|
|
|
|
* @param channel
|
|
|
|
* @param template
|
|
|
|
* @param message
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String ircChatToGameTokenizer(PurpleBot ircBot, User user, org.pircbotx.Channel channel, String template, String message) {
|
|
|
|
String ircNick = user.getNick();
|
|
|
|
String tmpl;
|
|
|
|
Player player = this.getPlayer(ircNick);
|
|
|
|
if (player != null) {
|
|
|
|
tmpl = playerTokenizer(player, template);
|
|
|
|
} else {
|
|
|
|
plugin.logDebug("ircChatToGameTokenizer: null player: " + ircNick);
|
|
|
|
tmpl = playerTokenizer(ircNick, template);
|
|
|
|
}
|
2016-07-02 18:05:48 +02:00
|
|
|
String nickPrefix = ircBot.getNickPrefix(user, channel);
|
|
|
|
String channelPrefix = ircBot.getChannelPrefix(channel);
|
|
|
|
if (nickPrefix == null) {
|
|
|
|
nickPrefix = "";
|
|
|
|
}
|
|
|
|
if (channelPrefix == null) {
|
|
|
|
channelPrefix = "";
|
|
|
|
}
|
2015-02-28 04:00:00 +01:00
|
|
|
return plugin.colorConverter.ircColorsToGame(ircUserTokenizer(tmpl, user, ircBot)
|
2016-07-02 18:05:48 +02:00
|
|
|
.replace("%NICKPREFIX%", nickPrefix)
|
|
|
|
.replace("%CHANNELPREFIX%", channelPrefix)
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%MESSAGE%", message)
|
|
|
|
.replace("%CHANNEL%", channel.getName()));
|
|
|
|
}
|
2016-07-31 21:44:15 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Normal IRC to game chat tokenizer
|
|
|
|
*
|
|
|
|
* @param ircBot
|
|
|
|
* @param user
|
|
|
|
* @param channel
|
|
|
|
* @param template
|
|
|
|
* @param oldTopic
|
|
|
|
* @param topic
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String ircTopicToGameTokenizer(PurpleBot ircBot, User user, org.pircbotx.Channel channel, String template, String oldTopic, String topic) {
|
|
|
|
String ircNick = user.getNick();
|
|
|
|
String tmpl;
|
|
|
|
Player player = this.getPlayer(ircNick);
|
|
|
|
if (player != null) {
|
|
|
|
tmpl = playerTokenizer(player, template);
|
|
|
|
} else {
|
|
|
|
plugin.logDebug("ircTopicToGameTokenizer: null player: " + ircNick);
|
|
|
|
tmpl = playerTokenizer(ircNick, template);
|
|
|
|
}
|
|
|
|
String nickPrefix = ircBot.getNickPrefix(user, channel);
|
|
|
|
String channelPrefix = ircBot.getChannelPrefix(channel);
|
|
|
|
if (nickPrefix == null) {
|
|
|
|
nickPrefix = "";
|
|
|
|
}
|
|
|
|
if (channelPrefix == null) {
|
|
|
|
channelPrefix = "";
|
|
|
|
}
|
|
|
|
return plugin.colorConverter.ircColorsToGame(ircUserTokenizer(tmpl, user, ircBot)
|
|
|
|
.replace("%NICKPREFIX%", nickPrefix)
|
|
|
|
.replace("%CHANNELPREFIX%", channelPrefix)
|
|
|
|
.replace("%MESSAGE%", topic)
|
|
|
|
.replace("%TOPIC%", topic)
|
|
|
|
.replace("%OLDTOPIC%", oldTopic)
|
|
|
|
.replace("%CHANNEL%", channel.getName()));
|
|
|
|
}
|
2015-01-01 20:38:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* IRC to Hero chat channel tokenizer
|
|
|
|
*
|
|
|
|
* @param ircBot
|
|
|
|
* @param user
|
|
|
|
* @param channel
|
|
|
|
* @param template
|
|
|
|
* @param message
|
|
|
|
* @param channelManager
|
|
|
|
* @param hChannel
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String ircChatToHeroChatTokenizer(PurpleBot ircBot, User user, org.pircbotx.Channel channel, String template, String message, ChannelManager channelManager, String hChannel) {
|
|
|
|
String ircNick = user.getNick();
|
2016-04-11 00:35:14 +02:00
|
|
|
String heroNick = "";
|
|
|
|
String heroColor = "";
|
2015-01-01 20:38:43 +01:00
|
|
|
String tmpl;
|
2016-04-11 00:35:14 +02:00
|
|
|
if (channelManager.getChannel(hChannel) == null) {
|
|
|
|
plugin.logError("Herochat channel is invalid: " + hChannel);
|
|
|
|
} else {
|
|
|
|
heroNick = channelManager.getChannel(hChannel).getNick();
|
|
|
|
heroColor = channelManager.getChannel(hChannel).getColor().toString();
|
|
|
|
}
|
2015-01-01 20:38:43 +01:00
|
|
|
Player player = this.getPlayer(ircNick);
|
|
|
|
if (player != null) {
|
|
|
|
tmpl = playerTokenizer(player, template);
|
|
|
|
} else {
|
|
|
|
tmpl = playerTokenizer(ircNick, template);
|
|
|
|
}
|
2016-04-11 00:35:14 +02:00
|
|
|
plugin.logDebug(message);
|
2015-02-28 04:00:00 +01:00
|
|
|
return plugin.colorConverter.ircColorsToGame(ircUserTokenizer(tmpl, user, ircBot)
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%HEROCHANNEL%", hChannel)
|
2016-04-11 00:35:14 +02:00
|
|
|
.replace("%HERONICK%", heroNick)
|
|
|
|
.replace("%HEROCOLOR%", heroColor)
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%NICKPREFIX%", ircBot.getNickPrefix(user, channel))
|
2015-04-22 07:00:12 +02:00
|
|
|
.replace("%CHANNELPREFIX%", ircBot.getChannelPrefix(channel))
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%MESSAGE%", message)
|
|
|
|
.replace("%CHANNEL%", channel.getName()));
|
|
|
|
}
|
|
|
|
|
2015-12-19 06:43:53 +01:00
|
|
|
/**
|
2016-02-17 06:52:08 +01:00
|
|
|
* IRC to VentureChat channel tokenizer
|
2015-12-19 06:43:53 +01:00
|
|
|
*
|
|
|
|
* @param ircBot
|
|
|
|
* @param user
|
|
|
|
* @param channel
|
|
|
|
* @param template
|
|
|
|
* @param message
|
|
|
|
* @param hChannel
|
|
|
|
* @return
|
|
|
|
*/
|
2016-02-17 06:52:08 +01:00
|
|
|
public String ircChatToVentureChatTokenizer(PurpleBot ircBot, User user, org.pircbotx.Channel channel, String template, String message, String hChannel) {
|
2015-12-19 06:43:53 +01:00
|
|
|
String ircNick = user.getNick();
|
|
|
|
String tmpl;
|
|
|
|
Player player = this.getPlayer(ircNick);
|
|
|
|
if (player != null) {
|
|
|
|
tmpl = playerTokenizer(player, template);
|
|
|
|
} else {
|
|
|
|
tmpl = playerTokenizer(ircNick, template);
|
|
|
|
}
|
|
|
|
return plugin.colorConverter.ircColorsToGame(ircUserTokenizer(tmpl, user, ircBot)
|
|
|
|
.replace("%MVCHANNEL%", hChannel)
|
|
|
|
.replace("%NICKPREFIX%", ircBot.getNickPrefix(user, channel))
|
|
|
|
.replace("%CHANNELPREFIX%", ircBot.getChannelPrefix(channel))
|
|
|
|
.replace("%MESSAGE%", message)
|
|
|
|
.replace("%CHANNEL%", channel.getName()));
|
|
|
|
}
|
|
|
|
|
2015-01-01 20:38:43 +01:00
|
|
|
/**
|
|
|
|
* IRC to Hero chat channel tokenizer
|
|
|
|
*
|
|
|
|
* @param ircBot
|
|
|
|
* @param user
|
|
|
|
* @param channel
|
|
|
|
* @param template
|
|
|
|
* @param message
|
|
|
|
* @param tChannel
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String ircChatToTownyChatTokenizer(PurpleBot ircBot, User user, org.pircbotx.Channel channel, String template, String message, String tChannel) {
|
|
|
|
String ircNick = user.getNick();
|
|
|
|
String tmpl;
|
|
|
|
Player player = this.getPlayer(ircNick);
|
|
|
|
if (player != null) {
|
|
|
|
tmpl = playerTokenizer(player, template);
|
|
|
|
} else {
|
|
|
|
tmpl = playerTokenizer(ircNick, template);
|
|
|
|
}
|
2015-02-28 04:00:00 +01:00
|
|
|
return plugin.colorConverter.ircColorsToGame(ircUserTokenizer(tmpl, user, ircBot)
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%TOWNYCHANNEL%", tChannel)
|
|
|
|
.replace("%NICKPREFIX%", ircBot.getNickPrefix(user, channel))
|
2015-04-22 07:00:12 +02:00
|
|
|
.replace("%CHANNELPREFIX%", ircBot.getChannelPrefix(channel))
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%MESSAGE%", message)
|
|
|
|
.replace("%CHANNEL%", channel.getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IRC kick message to game
|
|
|
|
*
|
|
|
|
* @param ircBot
|
|
|
|
* @param recipient
|
|
|
|
* @param kicker
|
|
|
|
* @param reason
|
|
|
|
* @param channel
|
|
|
|
* @param template
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String ircKickTokenizer(PurpleBot ircBot, User recipient, User kicker, String reason, org.pircbotx.Channel channel, String template) {
|
2015-02-28 04:00:00 +01:00
|
|
|
return plugin.colorConverter.ircColorsToGame(ircUserTokenizer(template, recipient, kicker, ircBot)
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%NICKPREFIX%", ircBot.getNickPrefix(kicker, channel))
|
2015-04-22 07:00:12 +02:00
|
|
|
.replace("%CHANNELPREFIX%", ircBot.getChannelPrefix(channel))
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%REASON%", reason)
|
|
|
|
.replace("%CHANNEL%", channel.getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IRC to hero kick message
|
|
|
|
*
|
|
|
|
* @param ircBot
|
|
|
|
* @param recipient
|
|
|
|
* @param kicker
|
|
|
|
* @param reason
|
|
|
|
* @param channel
|
|
|
|
* @param template
|
|
|
|
* @param channelManager
|
|
|
|
* @param hChannel
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String ircKickToHeroChatTokenizer(PurpleBot ircBot, User recipient, User kicker, String reason, org.pircbotx.Channel channel, String template, ChannelManager channelManager, String hChannel) {
|
2015-02-28 04:00:00 +01:00
|
|
|
return plugin.colorConverter.ircColorsToGame(ircUserTokenizer(template, recipient, kicker, ircBot)
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%HEROCHANNEL%", hChannel)
|
|
|
|
.replace("%HERONICK%", channelManager.getChannel(hChannel).getNick())
|
|
|
|
.replace("%HEROCOLOR%", channelManager.getChannel(hChannel).getColor().toString())
|
|
|
|
.replace("%NICKPREFIX%", ircBot.getNickPrefix(kicker, channel))
|
2015-04-22 07:00:12 +02:00
|
|
|
.replace("%CHANNELPREFIX%", ircBot.getChannelPrefix(channel))
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%REASON%", reason)
|
|
|
|
.replace("%CHANNEL%", channel.getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IRC mode change messages
|
|
|
|
*
|
|
|
|
* @param ircBot
|
|
|
|
* @param user
|
|
|
|
* @param mode
|
|
|
|
* @param channel
|
|
|
|
* @param template
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String ircModeTokenizer(PurpleBot ircBot, User user, String mode, org.pircbotx.Channel channel, String template) {
|
2015-02-28 04:00:00 +01:00
|
|
|
return plugin.colorConverter.ircColorsToGame(ircUserTokenizer(template, user, ircBot)
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%MODE%", mode)
|
|
|
|
.replace("%NICKPREFIX%", ircBot.getNickPrefix(user, channel))
|
2015-04-22 07:00:12 +02:00
|
|
|
.replace("%CHANNELPREFIX%", ircBot.getChannelPrefix(channel))
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%CHANNEL%", channel.getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* IRC notice change messages
|
|
|
|
*
|
|
|
|
* @param ircBot
|
|
|
|
* @param user
|
|
|
|
* @param message
|
|
|
|
* @param notice
|
|
|
|
* @param channel
|
|
|
|
* @param template
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String ircNoticeTokenizer(PurpleBot ircBot, User user, String message, String notice, org.pircbotx.Channel channel, String template) {
|
2015-02-28 04:00:00 +01:00
|
|
|
return plugin.colorConverter.ircColorsToGame(ircUserTokenizer(template, user, ircBot)
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%NICKPREFIX%", ircBot.getNickPrefix(user, channel))
|
2015-04-22 07:00:12 +02:00
|
|
|
.replace("%CHANNELPREFIX%", ircBot.getChannelPrefix(channel))
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%MESSAGE%", message)
|
|
|
|
.replace("%NOTICE%", notice)
|
|
|
|
.replace("%CHANNEL%", channel.getName()));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Game chat to IRC
|
|
|
|
*
|
|
|
|
* @param pName
|
|
|
|
* @param template
|
|
|
|
*
|
|
|
|
* @param message
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String gameChatToIRCTokenizer(String pName, String template, String message) {
|
|
|
|
return plugin.colorConverter.gameColorsToIrc(template
|
|
|
|
.replace("%NAME%", pName)
|
2016-07-07 16:21:23 +02:00
|
|
|
.replace("%MESSAGE%", plugin.colorConverter.gameColorsToIrc(message))
|
|
|
|
.replace("%RAWMESSAGE%", ChatColor.stripColor(message))
|
|
|
|
);
|
2015-01-01 20:38:43 +01:00
|
|
|
}
|
2015-06-25 05:13:34 +02:00
|
|
|
|
2015-06-20 17:40:46 +02:00
|
|
|
/**
|
|
|
|
* Game chat to game (private messages)
|
|
|
|
*
|
2015-06-28 19:15:20 +02:00
|
|
|
* @param sender
|
2015-06-29 01:39:32 +02:00
|
|
|
* @param target
|
2015-06-20 17:40:46 +02:00
|
|
|
* @param template
|
|
|
|
* @param message
|
|
|
|
* @return
|
|
|
|
*/
|
2015-06-29 01:39:32 +02:00
|
|
|
public String gameChatTokenizer(CommandSender sender, String target, String template, String message) {
|
2015-06-28 19:15:20 +02:00
|
|
|
if (sender instanceof Player) {
|
|
|
|
return playerTokenizer((Player) sender, template)
|
2015-06-29 01:39:32 +02:00
|
|
|
.replace("%TARGET%", target)
|
2015-06-28 19:15:20 +02:00
|
|
|
.replace("%MESSAGE%", message);
|
|
|
|
} else {
|
|
|
|
return template.replace("%NAME%", sender.getName())
|
2015-06-29 01:39:32 +02:00
|
|
|
.replace("%TARGET%", target)
|
2015-06-28 19:15:20 +02:00
|
|
|
.replace("%MESSAGE%", message);
|
|
|
|
}
|
2015-06-20 17:40:46 +02:00
|
|
|
}
|
2015-01-01 20:38:43 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Game chat to IRC
|
|
|
|
*
|
|
|
|
* @param player
|
|
|
|
* @param template
|
|
|
|
* @param message
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String gameChatToIRCTokenizer(Player player, String template, String message) {
|
|
|
|
if (message == null) {
|
|
|
|
message = "";
|
|
|
|
}
|
2016-07-07 16:21:23 +02:00
|
|
|
return plugin.colorConverter.gameColorsToIrc(
|
|
|
|
playerTokenizer(player, template)
|
|
|
|
.replace("%MESSAGE%", message)
|
|
|
|
.replace("%RAWMESSAGE%", ChatColor.stripColor(message))
|
|
|
|
);
|
2015-01-01 20:38:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Game chat to IRC
|
|
|
|
*
|
2015-10-22 16:23:30 +02:00
|
|
|
* @param ircBot
|
|
|
|
* @param channelName
|
|
|
|
* @param player
|
|
|
|
* @param template
|
|
|
|
* @param message
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String gameChatToIRCTokenizer(PurpleBot ircBot, String channelName, Player player, String template, String message) {
|
|
|
|
if (message == null) {
|
|
|
|
message = "";
|
|
|
|
}
|
|
|
|
PlayerList pl = plugin.getMCPlayerList(ircBot, channelName);
|
|
|
|
return plugin.colorConverter.gameColorsToIrc(playerTokenizer(player, template)
|
|
|
|
.replace("%MESSAGE%", message)
|
2016-07-07 16:21:23 +02:00
|
|
|
.replace("%RAWMESSAGE%", ChatColor.stripColor(message))
|
2015-10-22 16:23:30 +02:00
|
|
|
.replace("%COUNT%", Integer.toString(pl.count))
|
|
|
|
.replace("%MAX%", Integer.toString(pl.max))
|
|
|
|
.replace("%PLAYERS%", pl.list)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dynmap web chat to IRC
|
|
|
|
*
|
2015-01-01 20:38:43 +01:00
|
|
|
* @param source
|
|
|
|
* @param name
|
|
|
|
* @param template
|
|
|
|
* @param message
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String dynmapWebChatToIRCTokenizer(String source, String name,
|
|
|
|
String template, String message) {
|
|
|
|
if (message == null) {
|
|
|
|
message = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
return plugin.colorConverter.gameColorsToIrc(
|
|
|
|
playerTokenizer(name, template)
|
|
|
|
.replace("%SOURCE%", source)
|
2016-07-07 16:21:23 +02:00
|
|
|
.replace("%MESSAGE%", message)
|
|
|
|
.replace("%RAWMESSAGE%", ChatColor.stripColor(message))
|
|
|
|
);
|
2015-01-01 20:38:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Game player AFK to IRC
|
|
|
|
*
|
|
|
|
* @param player
|
|
|
|
* @param template
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String gamePlayerAFKTokenizer(Player player, String template) {
|
|
|
|
return plugin.colorConverter.gameColorsToIrc(playerTokenizer(player, template));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mcMMO chat to IRC
|
|
|
|
*
|
|
|
|
* @param player
|
|
|
|
* @param template
|
|
|
|
*
|
|
|
|
* @param message
|
|
|
|
* @param partyName
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String mcMMOPartyChatToIRCTokenizer(Player player, String template, String message, String partyName) {
|
|
|
|
return mcMMOChatToIRCTokenizer(player, template, message)
|
|
|
|
.replace("%PARTY%", partyName);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* mcMMO chat to IRC
|
|
|
|
*
|
|
|
|
* @param player
|
|
|
|
* @param template
|
|
|
|
* @param message
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String mcMMOChatToIRCTokenizer(Player player, String template, String message) {
|
|
|
|
int powerLevel = UserManager.getPlayer(player).getPowerLevel();
|
|
|
|
return gameChatToIRCTokenizer(player, template, message)
|
|
|
|
.replace("%POWERLEVEL%", Integer.toString(powerLevel));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* FactionChat to IRC
|
|
|
|
*
|
|
|
|
* @param player
|
|
|
|
* @param botNick
|
|
|
|
* @param message
|
|
|
|
* @param chatTag
|
|
|
|
* @param chatMode
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String chatFactionTokenizer(Player player, String botNick, String message, String chatTag, String chatMode) {
|
|
|
|
String template;
|
|
|
|
switch (chatMode) {
|
|
|
|
case "public":
|
2015-12-19 06:43:53 +01:00
|
|
|
template = plugin.getMessageTemplate(botNick, "", TemplateName.FACTION_PUBLIC_CHAT);
|
2015-01-01 20:38:43 +01:00
|
|
|
break;
|
|
|
|
case "ally":
|
2015-12-19 06:43:53 +01:00
|
|
|
template = plugin.getMessageTemplate(botNick, "", TemplateName.FACTION_ALLY_CHAT);
|
2015-01-01 20:38:43 +01:00
|
|
|
break;
|
|
|
|
case "enemy":
|
2015-12-19 06:43:53 +01:00
|
|
|
template = plugin.getMessageTemplate(botNick, "", TemplateName.FACTION_ENEMY_CHAT);
|
2015-01-01 20:38:43 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
return plugin.colorConverter.gameColorsToIrc(
|
|
|
|
gameChatToIRCTokenizer(player, template, message)
|
|
|
|
.replace("%FACTIONTAG%", chatTag)
|
|
|
|
.replace("%FACTIONMODE%", chatMode));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Herochat to IRC
|
|
|
|
*
|
|
|
|
* @param player
|
|
|
|
* @param message
|
|
|
|
* @param hColor
|
|
|
|
* @param hChannel
|
|
|
|
* @param hNick
|
|
|
|
* @param template
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String chatHeroTokenizer(Player player, String message, String hColor, String hChannel, String hNick, String template) {
|
|
|
|
return gameChatToIRCTokenizer(player, template, message)
|
|
|
|
.replace("%HEROCHANNEL%", hChannel)
|
|
|
|
.replace("%HERONICK%", hNick)
|
|
|
|
.replace("%HEROCOLOR%", plugin.colorConverter.gameColorsToIrc(hColor))
|
|
|
|
.replace("%CHANNEL%", hChannel);
|
|
|
|
}
|
|
|
|
|
2015-06-29 01:39:32 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param player
|
|
|
|
* @param townyChannel
|
|
|
|
* @param message
|
|
|
|
* @param template
|
|
|
|
* @return
|
|
|
|
*/
|
2015-01-01 20:38:43 +01:00
|
|
|
public String chatTownyChannelTokenizer(Player player, Channel townyChannel, String message, String template) {
|
|
|
|
|
|
|
|
return gameChatToIRCTokenizer(player, template, message)
|
|
|
|
.replace("%TOWNYCHANNEL%", ChatColor.translateAlternateColorCodes('&', townyChannel.getName()))
|
|
|
|
.replace("%TOWNYCHANNELTAG%", ChatColor.translateAlternateColorCodes('&', townyChannel.getChannelTag()))
|
|
|
|
.replace("%TOWNYMSGCOLOR%", ChatColor.translateAlternateColorCodes('&', townyChannel.getMessageColour()));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TitanChat to IRC
|
|
|
|
*
|
|
|
|
* @param player
|
|
|
|
* @param tChannel
|
|
|
|
* @param tColor
|
|
|
|
* @param message
|
|
|
|
* @param template
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String titanChatTokenizer(Player player, String tChannel, String tColor, String message, String template) {
|
|
|
|
return gameChatToIRCTokenizer(player, template, message)
|
|
|
|
.replace("%TITANCHANNEL%", tChannel)
|
|
|
|
.replace("%TITANCOLOR%", plugin.colorConverter.gameColorsToIrc(tColor))
|
|
|
|
.replace("%CHANNEL%", tChannel);
|
|
|
|
}
|
|
|
|
|
2015-12-19 06:43:53 +01:00
|
|
|
/**
|
2016-02-17 06:52:08 +01:00
|
|
|
* VentureChat to IRC
|
2015-12-19 06:43:53 +01:00
|
|
|
*
|
|
|
|
* @param player
|
2016-02-17 06:52:08 +01:00
|
|
|
* @param vcChannel
|
|
|
|
* @param vcColor
|
2015-12-19 06:43:53 +01:00
|
|
|
* @param message
|
|
|
|
* @param template
|
|
|
|
* @return
|
|
|
|
*/
|
2016-02-17 06:52:08 +01:00
|
|
|
public String ventureChatTokenizer(Player player, String vcChannel, String vcColor, String message, String template) {
|
2015-12-19 06:43:53 +01:00
|
|
|
return gameChatToIRCTokenizer(player, template, message)
|
2016-02-17 06:52:08 +01:00
|
|
|
.replace("%MVCHANNEL%", vcChannel)
|
|
|
|
.replace("%MVCOLOR%", plugin.colorConverter.gameColorsToIrc(vcColor))
|
|
|
|
.replace("%CHANNEL%", vcChannel);
|
2015-12-19 06:43:53 +01:00
|
|
|
}
|
|
|
|
|
2015-01-01 20:38:43 +01:00
|
|
|
/**
|
|
|
|
* Game chat to IRC
|
|
|
|
*
|
|
|
|
* @param template
|
|
|
|
* @param message
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String gameChatToIRCTokenizer(String template, String message) {
|
|
|
|
return plugin.colorConverter.gameColorsToIrc(template
|
2016-07-07 16:21:23 +02:00
|
|
|
.replace("%MESSAGE%", message)
|
|
|
|
.replace("%RAWMESSAGE%", ChatColor.stripColor(message))
|
|
|
|
);
|
2015-01-01 20:38:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Game kick message to IRC
|
|
|
|
*
|
|
|
|
* @param player
|
|
|
|
* @param template
|
|
|
|
* @param reason
|
|
|
|
* @param message
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String gameKickTokenizer(Player player, String template, String message, String reason) {
|
|
|
|
return plugin.colorConverter.gameColorsToIrc(
|
|
|
|
gameChatToIRCTokenizer(player, template, message)
|
|
|
|
.replace("%MESSAGE%", message)
|
2016-07-07 16:21:23 +02:00
|
|
|
.replace("%RAWMESSAGE%", ChatColor.stripColor(message))
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%REASON%", reason));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ReportRTS notifications to IRC
|
|
|
|
*
|
|
|
|
* @param pName
|
|
|
|
* @param template
|
|
|
|
* @param ticket
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String reportRTSTokenizer(String pName, String template, Ticket ticket) {
|
|
|
|
String message = ticket.getMessage();
|
2016-04-18 07:13:59 +02:00
|
|
|
String modName = ticket.getStaffName();
|
2015-01-01 20:38:43 +01:00
|
|
|
String displayModName = "";
|
|
|
|
String name = ticket.getName();
|
|
|
|
String world = ticket.getWorld();
|
2016-04-18 08:30:50 +02:00
|
|
|
String modComment = "";
|
|
|
|
if (!ticket.getComments().isEmpty()) {
|
|
|
|
modComment = ticket.getComments().last().getComment();
|
|
|
|
}
|
2015-01-01 20:38:43 +01:00
|
|
|
int id = ticket.getId();
|
|
|
|
if (message == null) {
|
|
|
|
message = "";
|
|
|
|
}
|
|
|
|
if (modName == null) {
|
|
|
|
modName = "";
|
|
|
|
} else {
|
|
|
|
Player player = this.getPlayer(modName);
|
|
|
|
if (player != null) {
|
|
|
|
displayModName = player.getDisplayName();
|
|
|
|
} else {
|
|
|
|
displayModName = modName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (name == null) {
|
|
|
|
name = "";
|
|
|
|
}
|
|
|
|
if (world == null) {
|
|
|
|
world = "";
|
|
|
|
}
|
|
|
|
if (modComment == null) {
|
|
|
|
modComment = "";
|
|
|
|
}
|
|
|
|
return plugin.colorConverter.gameColorsToIrc(playerTokenizer(pName, template)
|
|
|
|
.replace("%MESSAGE%", message)
|
2016-07-07 16:21:23 +02:00
|
|
|
.replace("%RAWMESSAGE%", ChatColor.stripColor(message))
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%MODNAME%", modName)
|
|
|
|
.replace("%DISPLAYMODNAME%", displayModName)
|
|
|
|
.replace("%MODCOMMENT%", modComment)
|
|
|
|
.replace("%TICKETNUMBER%", String.valueOf(id))
|
|
|
|
.replace("%RTSNAME%", name)
|
|
|
|
.replace("%RTSWORLD%", world));
|
|
|
|
}
|
|
|
|
|
2015-12-21 15:38:40 +01:00
|
|
|
/**
|
|
|
|
* SimpleTicketManager notifications to IRC
|
|
|
|
*
|
|
|
|
* @param uuid
|
|
|
|
* @param template
|
|
|
|
* @param ticket
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String simpleTicketTokenizer(UUID uuid, String template,
|
|
|
|
uk.co.joshuawoolley.simpleticketmanager.ticketsystem.Ticket ticket) {
|
|
|
|
Player player = Bukkit.getPlayer(uuid);
|
|
|
|
String playerName;
|
|
|
|
String displayName;
|
|
|
|
if (player == null) {
|
|
|
|
playerName = uuid.toString();
|
|
|
|
displayName = uuid.toString();
|
|
|
|
} else {
|
|
|
|
playerName = player.getName();
|
|
|
|
displayName = player.getCustomName();
|
|
|
|
}
|
|
|
|
String description = ticket.getDescription();
|
|
|
|
String reason = ticket.getReason();
|
|
|
|
String modUUID = ticket.getAssignedTo();
|
|
|
|
String modName;
|
|
|
|
String displayModName;
|
|
|
|
String name = ticket.getReportingPlayer();
|
|
|
|
String world = ticket.getWorld();
|
|
|
|
String modComment = "";
|
|
|
|
int id = ticket.getTicketId();
|
|
|
|
if (description == null) {
|
|
|
|
description = "";
|
|
|
|
}
|
|
|
|
Player modPlayer = null;
|
|
|
|
if (modUUID != null) {
|
|
|
|
modPlayer = Bukkit.getPlayer(UUID.fromString(modUUID));
|
|
|
|
}
|
|
|
|
if (modPlayer != null) {
|
|
|
|
modName = modPlayer.getName();
|
|
|
|
displayModName = modPlayer.getDisplayName();
|
|
|
|
} else {
|
|
|
|
modName = modUUID;
|
|
|
|
displayModName = modName;
|
|
|
|
}
|
|
|
|
if (name == null) {
|
|
|
|
name = "";
|
|
|
|
}
|
|
|
|
if (world == null) {
|
|
|
|
world = "";
|
|
|
|
}
|
|
|
|
if (modName == null) {
|
|
|
|
modName = "";
|
|
|
|
}
|
|
|
|
if (displayModName == null) {
|
|
|
|
displayModName = "";
|
|
|
|
}
|
|
|
|
return plugin.colorConverter.gameColorsToIrc(playerTokenizer(playerName, template)
|
|
|
|
.replace("%MESSAGE%", description)
|
|
|
|
.replace("%MODNAME%", modName)
|
|
|
|
.replace("%DISPLAYMODNAME%", displayModName)
|
|
|
|
.replace("%MODCOMMENT%", modComment)
|
|
|
|
.replace("%TICKETNUMBER%", String.valueOf(id))
|
|
|
|
.replace("%NAME%", name)
|
|
|
|
.replace("%DISPLAYNAME%", displayName)
|
|
|
|
.replace("%REASON%", reason)
|
|
|
|
.replace("%WORLD%", world));
|
|
|
|
}
|
|
|
|
|
2015-06-29 01:39:32 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param sender
|
|
|
|
* @param message
|
|
|
|
* @param template
|
|
|
|
* @return
|
|
|
|
*/
|
2015-01-01 20:38:43 +01:00
|
|
|
public String reportRTSTokenizer(CommandSender sender, String message, String template) {
|
|
|
|
return gameChatToIRCTokenizer(sender.getName(), template, message);
|
|
|
|
}
|
|
|
|
|
2015-06-29 01:39:32 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param player
|
|
|
|
* @param message
|
|
|
|
* @return
|
|
|
|
*/
|
2015-01-01 20:38:43 +01:00
|
|
|
public String playerTokenizer(Player player, String message) {
|
2015-12-06 06:17:30 +01:00
|
|
|
String pName;
|
2016-04-30 07:16:00 +02:00
|
|
|
String displayName;
|
2015-12-06 06:17:30 +01:00
|
|
|
if (plugin.pingFixTemplate) {
|
|
|
|
pName = addZeroWidthSpace(player.getName());
|
2016-05-01 07:10:26 +02:00
|
|
|
displayName = player.getDisplayName().replace(player.getName(), pName);
|
2015-12-06 06:17:30 +01:00
|
|
|
} else {
|
|
|
|
pName = player.getName();
|
2016-04-30 07:16:00 +02:00
|
|
|
displayName = player.getDisplayName();
|
2015-12-06 06:17:30 +01:00
|
|
|
}
|
2015-01-01 20:38:43 +01:00
|
|
|
plugin.logDebug("Tokenizing " + pName + "(O: " + player.isOnline() + ")");
|
|
|
|
String pSuffix = plugin.getPlayerSuffix(player);
|
|
|
|
String pPrefix = plugin.getPlayerPrefix(player);
|
|
|
|
String gPrefix = plugin.getGroupPrefix(player);
|
|
|
|
String gSuffix = plugin.getGroupSuffix(player);
|
|
|
|
String group = plugin.getPlayerGroup(player);
|
2016-07-06 07:05:30 +02:00
|
|
|
|
2016-01-09 02:00:47 +01:00
|
|
|
UUID uuid = player.getUniqueId();
|
2015-09-27 20:06:36 +02:00
|
|
|
String playerIP = "";
|
|
|
|
try {
|
2015-11-06 23:08:22 +01:00
|
|
|
playerIP = player.getAddress().getAddress().getHostAddress();
|
2015-09-27 20:06:36 +02:00
|
|
|
} catch (Exception ex) {
|
|
|
|
plugin.logDebug(ex.getMessage());
|
|
|
|
}
|
2015-01-17 21:03:42 +01:00
|
|
|
String host = plugin.getPlayerHost(playerIP);
|
2015-01-01 20:38:43 +01:00
|
|
|
String worldName = "";
|
|
|
|
String worldAlias = "";
|
|
|
|
String worldColor = "";
|
|
|
|
String jobShort = "";
|
|
|
|
String job = "";
|
|
|
|
if (pSuffix == null) {
|
|
|
|
pSuffix = "";
|
|
|
|
}
|
|
|
|
if (pPrefix == null) {
|
|
|
|
pPrefix = "";
|
|
|
|
}
|
|
|
|
if (gSuffix == null) {
|
|
|
|
gSuffix = "";
|
|
|
|
}
|
|
|
|
if (gPrefix == null) {
|
|
|
|
gPrefix = "";
|
|
|
|
}
|
|
|
|
if (group == null) {
|
|
|
|
group = "";
|
|
|
|
}
|
|
|
|
if (playerIP == null) {
|
|
|
|
playerIP = "";
|
|
|
|
}
|
|
|
|
if (displayName == null) {
|
|
|
|
displayName = "";
|
|
|
|
}
|
|
|
|
if (player.getWorld() != null) {
|
|
|
|
worldName = player.getWorld().getName();
|
|
|
|
worldAlias = plugin.getWorldAlias(worldName);
|
|
|
|
worldColor = plugin.getWorldColor(worldName);
|
|
|
|
}
|
2015-03-16 18:32:15 +01:00
|
|
|
if (message.contains("%JOBS%") || message.contains("%JOBSSHORT%")) {
|
|
|
|
if (plugin.jobsHook != null) {
|
|
|
|
job = plugin.jobsHook.getPlayerJob(player, false);
|
|
|
|
jobShort = plugin.jobsHook.getPlayerJob(player, true);
|
|
|
|
}
|
2015-01-01 20:38:43 +01:00
|
|
|
}
|
|
|
|
plugin.logDebug("[P]Raw message: " + message);
|
|
|
|
return message.replace("%DISPLAYNAME%", displayName)
|
2016-01-09 02:00:47 +01:00
|
|
|
.replace("%UUID%", uuid.toString())
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%JOBS%", job)
|
|
|
|
.replace("%JOBSSHORT%", jobShort)
|
|
|
|
.replace("%NAME%", pName)
|
|
|
|
.replace("%PLAYERIP%", playerIP)
|
|
|
|
.replace("%HOST%", host)
|
|
|
|
.replace("%GROUP%", group)
|
|
|
|
.replace("%PLAYERPREFIX%", pPrefix)
|
|
|
|
.replace("%PLAYERSUFFIX%", pSuffix)
|
|
|
|
.replace("%GROUPPREFIX%", gPrefix)
|
|
|
|
.replace("%GROUPSUFFIX%", gSuffix)
|
|
|
|
.replace("%WORLDALIAS%", worldAlias)
|
|
|
|
.replace("%WORLDCOLOR%", worldColor)
|
|
|
|
.replace("%WORLD%", worldName);
|
|
|
|
}
|
|
|
|
|
|
|
|
private String playerTokenizer(String playerName, String message) {
|
2016-01-09 02:00:47 +01:00
|
|
|
Player player = getPlayer(playerName);
|
2015-01-01 20:38:43 +01:00
|
|
|
plugin.logDebug("Tokenizing " + playerName);
|
|
|
|
String worldName = plugin.defaultPlayerWorld;
|
2015-03-16 18:32:15 +01:00
|
|
|
|
2015-03-16 15:01:00 +01:00
|
|
|
String pSuffix = "";
|
|
|
|
String pPrefix = "";
|
|
|
|
String gSuffix = "";
|
|
|
|
String gPrefix = "";
|
|
|
|
String group = "";
|
2015-03-16 18:32:15 +01:00
|
|
|
|
2015-03-16 15:01:00 +01:00
|
|
|
if (message.contains("%PLAYERSUFFIX%")) {
|
|
|
|
pSuffix = plugin.getPlayerSuffix(worldName, playerName);
|
|
|
|
}
|
|
|
|
if (message.contains("%PLAYERPREFIX%")) {
|
|
|
|
pPrefix = plugin.getPlayerPrefix(worldName, playerName);
|
|
|
|
}
|
|
|
|
if (message.contains("%GROUPSUFFIX%")) {
|
2015-08-17 01:33:02 +02:00
|
|
|
gSuffix = plugin.getGroupSuffix(worldName, playerName);
|
2015-03-16 15:01:00 +01:00
|
|
|
}
|
|
|
|
if (message.contains("%GROUPPREFIX%")) {
|
2015-08-17 01:33:02 +02:00
|
|
|
gPrefix = plugin.getGroupPrefix(worldName, playerName);
|
2015-03-16 15:01:00 +01:00
|
|
|
}
|
|
|
|
if (message.contains("%GROUP%")) {
|
|
|
|
group = plugin.getPlayerGroup(worldName, playerName);
|
|
|
|
}
|
2015-03-16 18:32:15 +01:00
|
|
|
|
2015-01-01 20:38:43 +01:00
|
|
|
String displayName = plugin.getDisplayName(playerName);
|
2016-01-09 02:00:47 +01:00
|
|
|
String uuid = "";
|
2015-01-01 20:38:43 +01:00
|
|
|
plugin.logDebug("playerTokenizer: 7 ");
|
|
|
|
String worldAlias = "";
|
|
|
|
String worldColor = "";
|
|
|
|
String jobShort = "";
|
|
|
|
String job = "";
|
|
|
|
plugin.logDebug("playerTokenizer: 8 ");
|
|
|
|
if (!worldName.isEmpty()) {
|
|
|
|
worldAlias = plugin.getWorldAlias(worldName);
|
|
|
|
worldColor = plugin.getWorldColor(worldName);
|
|
|
|
}
|
|
|
|
plugin.logDebug("playerTokenizer: 9 ");
|
|
|
|
if (pSuffix == null) {
|
|
|
|
pSuffix = plugin.defaultPlayerSuffix;
|
|
|
|
}
|
|
|
|
plugin.logDebug("playerTokenizer: 10 ");
|
|
|
|
if (pPrefix == null) {
|
|
|
|
pPrefix = plugin.defaultPlayerPrefix;
|
|
|
|
}
|
|
|
|
plugin.logDebug("playerTokenizer: 11 ");
|
|
|
|
if (gSuffix == null) {
|
|
|
|
gSuffix = plugin.defaultGroupSuffix;
|
|
|
|
}
|
|
|
|
plugin.logDebug("playerTokenizer: 12 ");
|
|
|
|
if (gPrefix == null) {
|
|
|
|
gPrefix = plugin.defaultGroupPrefix;
|
|
|
|
}
|
|
|
|
plugin.logDebug("playerTokenizer: 13 ");
|
|
|
|
if (group == null) {
|
|
|
|
group = plugin.defaultPlayerGroup;
|
|
|
|
}
|
|
|
|
plugin.logDebug("playerTokenizer: 14 ");
|
2016-01-09 02:00:47 +01:00
|
|
|
if (player != null) {
|
|
|
|
uuid = player.getUniqueId().toString();
|
|
|
|
if (message.contains("%JOBS%") || message.contains("%JOBSSHORT%")) {
|
2015-03-16 18:32:15 +01:00
|
|
|
if (plugin.jobsHook != null) {
|
|
|
|
job = plugin.jobsHook.getPlayerJob(player, false);
|
|
|
|
jobShort = plugin.jobsHook.getPlayerJob(player, true);
|
|
|
|
}
|
2015-01-01 20:38:43 +01:00
|
|
|
}
|
|
|
|
}
|
2016-01-09 02:00:47 +01:00
|
|
|
|
2015-01-01 20:38:43 +01:00
|
|
|
plugin.logDebug("[S]Raw message: " + message);
|
|
|
|
return message.replace("%DISPLAYNAME%", displayName)
|
2016-01-09 02:00:47 +01:00
|
|
|
.replace("%UUID%", uuid)
|
2015-01-01 20:38:43 +01:00
|
|
|
.replace("%JOBS%", job)
|
|
|
|
.replace("%JOBSSHORT%", jobShort)
|
|
|
|
.replace("%NAME%", playerName)
|
|
|
|
.replace("%GROUP%", group)
|
|
|
|
.replace("%PLAYERPREFIX%", pPrefix)
|
|
|
|
.replace("%PLAYERSUFFIX%", pSuffix)
|
|
|
|
.replace("%GROUPSUFFIX%", gSuffix)
|
|
|
|
.replace("%GROUPPREFIX%", gPrefix)
|
|
|
|
.replace("%WORLDALIAS%", worldAlias)
|
|
|
|
.replace("%WORLDCOLOR%", worldColor)
|
|
|
|
.replace("%WORLD%", worldName);
|
|
|
|
}
|
|
|
|
|
|
|
|
private Player getPlayer(String name) {
|
|
|
|
Player player;
|
|
|
|
if (plugin.exactNickMatch) {
|
|
|
|
plugin.logDebug("Checking for exact player matching " + name);
|
|
|
|
player = plugin.getServer().getPlayerExact(name);
|
|
|
|
} else {
|
|
|
|
plugin.logDebug("Checking for player matching " + name);
|
|
|
|
player = plugin.getServer().getPlayer(name);
|
|
|
|
}
|
|
|
|
return player;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param player
|
|
|
|
* @param template
|
|
|
|
* @param cmd
|
|
|
|
* @param params
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String gameCommandToIRCTokenizer(Player player, String template, String cmd, String params) {
|
|
|
|
return plugin.colorConverter.gameColorsToIrc(playerTokenizer(player, template)
|
|
|
|
.replace("%COMMAND%", cmd)
|
|
|
|
.replace("%PARAMS%", params));
|
|
|
|
}
|
|
|
|
|
2015-06-29 01:39:32 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param target
|
|
|
|
* @param message
|
|
|
|
* @param template
|
|
|
|
* @return
|
|
|
|
*/
|
2015-01-01 20:38:43 +01:00
|
|
|
public String targetChatResponseTokenizer(String target, String message, String template) {
|
|
|
|
return plugin.colorConverter.gameColorsToIrc(template
|
|
|
|
.replace("%TARGET%", target)
|
|
|
|
.replace("%MESSAGE%", message)
|
2016-07-07 16:21:23 +02:00
|
|
|
.replace("%RAWMESSAGE%", ChatColor.stripColor(message))
|
2015-01-01 20:38:43 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-06-29 01:39:32 +02:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param sender
|
|
|
|
* @param target
|
|
|
|
* @param message
|
|
|
|
* @param template
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String msgChatResponseTokenizer(CommandSender sender, String target, String message, String template) {
|
|
|
|
if (sender instanceof Player) {
|
|
|
|
return plugin.colorConverter.ircColorsToGame(
|
|
|
|
playerTokenizer((Player) sender, template)
|
|
|
|
.replace("%TARGET%", target)
|
|
|
|
.replace("%MESSAGE%", message)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return plugin.colorConverter.ircColorsToGame(template
|
|
|
|
.replace("%NAME%", sender.getName())
|
|
|
|
.replace("%TARGET%", target)
|
|
|
|
.replace("%MESSAGE%", message)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param target
|
|
|
|
* @param message
|
|
|
|
* @param template
|
|
|
|
* @return
|
|
|
|
*/
|
2015-01-01 20:38:43 +01:00
|
|
|
public String msgChatResponseTokenizer(String target, String message, String template) {
|
|
|
|
return plugin.colorConverter.ircColorsToGame(template
|
|
|
|
.replace("%TARGET%", target)
|
|
|
|
.replace("%MESSAGE%", message)
|
|
|
|
);
|
|
|
|
}
|
2016-01-09 02:00:47 +01:00
|
|
|
|
2016-01-07 06:57:44 +01:00
|
|
|
/**
|
|
|
|
*
|
|
|
|
* @param command
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String ircCommandSentTokenizer(String command) {
|
2016-01-09 02:00:47 +01:00
|
|
|
return plugin.colorConverter.gameColorsToIrc(
|
|
|
|
plugin.getMessageTemplate(TemplateName.COMMAND_SENT)
|
|
|
|
.replace("%COMMAND%", command));
|
2016-01-07 06:57:44 +01:00
|
|
|
}
|
2015-06-25 05:13:34 +02:00
|
|
|
|
2015-06-29 01:39:32 +02:00
|
|
|
/**
|
|
|
|
*
|
2015-11-06 23:08:22 +01:00
|
|
|
* @param sender
|
2015-06-29 01:39:32 +02:00
|
|
|
* @param targetPlayer
|
|
|
|
* @param message
|
|
|
|
* @param template
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
public String msgChatResponseTokenizer(CommandSender sender, Player targetPlayer, String message, String template) {
|
|
|
|
return template.replace("%NAME%", sender.getName())
|
|
|
|
.replace("%TARGET%", targetPlayer.getName())
|
2015-06-25 05:13:34 +02:00
|
|
|
.replace("%MESSAGE%", message);
|
|
|
|
}
|
2015-12-19 06:43:53 +01:00
|
|
|
|
2015-11-29 06:18:49 +01:00
|
|
|
public String logTailerTokenizer(String file, String line, String template) {
|
2015-12-03 04:43:38 +01:00
|
|
|
return plugin.colorConverter.gameColorsToIrc(template
|
2015-11-29 06:18:49 +01:00
|
|
|
.replace("%FILE%", file)
|
|
|
|
.replace("%LINE%", line));
|
|
|
|
}
|
2015-12-19 06:43:53 +01:00
|
|
|
|
2015-12-06 06:17:30 +01:00
|
|
|
public String addZeroWidthSpace(String s) {
|
|
|
|
if (s.length() > 1) {
|
|
|
|
String a = s.substring(0, 1);
|
|
|
|
String b = s.substring(1);
|
|
|
|
return a + "\u200B" + b;
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
2015-01-01 20:38:43 +01:00
|
|
|
}
|