mirror of
https://github.com/cnaude/PurpleIRC-spigot.git
synced 2024-11-25 19:45:54 +01:00
Add %CUSTOMPREFIX% to irc-nickchange template tokenizer.
This commit is contained in:
parent
debdcbffb8
commit
0cc1d3b044
@ -20,6 +20,7 @@ import com.cnaude.purpleirc.TemplateName;
|
||||
import com.cnaude.purpleirc.PurpleBot;
|
||||
import com.cnaude.purpleirc.PurpleIRC;
|
||||
import org.pircbotx.Channel;
|
||||
import org.pircbotx.User;
|
||||
import org.pircbotx.hooks.ListenerAdapter;
|
||||
import org.pircbotx.hooks.events.NickChangeEvent;
|
||||
|
||||
@ -50,18 +51,16 @@ public class NickChangeListener extends ListenerAdapter {
|
||||
public void onNickChange(NickChangeEvent event) {
|
||||
String newNick = event.getNewNick();
|
||||
String oldNick = event.getOldNick();
|
||||
User user = event.getUser();
|
||||
plugin.logDebug("OLD: " + oldNick);
|
||||
plugin.logDebug("NEW: " + newNick);
|
||||
|
||||
for (String channelName : ircBot.channelNicks.keySet()) {
|
||||
Channel channel = ircBot.getChannel(channelName);
|
||||
if (channel != null) {
|
||||
if (ircBot.enabledMessages.get(channelName).contains(TemplateName.IRC_NICK_CHANGE)) {
|
||||
plugin.broadcastToGame(plugin.colorConverter.ircColorsToGame(
|
||||
plugin.getMessageTemplate(ircBot.botNick, channelName, TemplateName.IRC_NICK_CHANGE)
|
||||
.replace("%NEWNICK%", newNick)
|
||||
.replace("%OLDNICK%", oldNick)
|
||||
.replace("%CHANNEL%", channelName)), "irc.message.nickchange");
|
||||
if (ircBot.enabledMessages.get(channelName).contains(TemplateName.IRC_NICK_CHANGE)) {
|
||||
String message = plugin.tokenizer.ircNickChangeTokenizer(user, oldNick, newNick, channelName, ircBot);
|
||||
plugin.broadcastToGame(message, "irc.message.nickchange");
|
||||
}
|
||||
if (plugin.netPackets != null) {
|
||||
plugin.netPackets.remFromTabList(oldNick);
|
||||
|
@ -108,6 +108,25 @@ public class ChatTokenizer {
|
||||
.replace("%SERVER%", server)
|
||||
.replace("%AWAY%", away);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param user
|
||||
* @param oldNick
|
||||
* @param newNick
|
||||
* @param channelName
|
||||
* @param ircBot
|
||||
* @return
|
||||
*/
|
||||
public String ircNickChangeTokenizer(User user, String oldNick, String newNick, String channelName, PurpleBot ircBot) {
|
||||
String template = plugin.getMessageTemplate(ircBot.botNick, channelName, TemplateName.IRC_NICK_CHANGE);
|
||||
String message = template.replace("%NEWNICK%", newNick)
|
||||
.replace("%OLDNICK%", oldNick)
|
||||
.replace("%CHANNEL%", channelName);
|
||||
message = plugin.colorConverter.ircColorsToGame(ircUserTokenizer(message, user, ircBot));
|
||||
|
||||
return plugin.colorConverter.ircColorsToGame(message);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user