Skip to content
This repository has been archived by the owner on Jul 27, 2019. It is now read-only.

Commit

Permalink
Minor fixes to dynmap hook
Browse files Browse the repository at this point in the history
  • Loading branch information
cnaude committed May 16, 2015
1 parent 92dc1af commit dadd45c
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/main/java/com/cnaude/purpleirc/PurpleBot.java
Expand Up @@ -2251,11 +2251,28 @@ public String filterMessage(String message, String myChannel) {
public void broadcastChat(User user, org.pircbotx.Channel channel, String target, String message, boolean override, boolean ctcpResponse) {
boolean messageSent = false;
String myChannel = channel.getName();

/*
First occurrence replacements
*/
if (!firstOccurrenceReplacements.isEmpty()) {
for (String key : firstOccurrenceReplacements.keySet()) {
if (user.getNick().equalsIgnoreCase(key) || checkUserMask(user, key)) {
CaseInsensitiveMap cm = firstOccurrenceReplacements.get(key);
for (Object obj : cm.keySet()) {
message = message.replaceFirst((String) obj, ChatColor.translateAlternateColorCodes('&', (String) cm.get(obj)));
}
}
}
}

/*
Send messages to Dynmap if enabled
*/
if (plugin.dynmapHook != null) {
if (isMessageEnabled(myChannel, TemplateName.IRC_DYNMAP_WEB_CHAT)) {
plugin.logDebug("Checking if " + TemplateName.IRC_DYNMAP_WEB_CHAT + " is enabled ...");
if (enabledMessages.get(myChannel).contains(TemplateName.IRC_DYNMAP_WEB_CHAT)) {
plugin.logDebug("Yes, " + TemplateName.IRC_DYNMAP_WEB_CHAT + " is enabled...");
plugin.logDebug("broadcastChat [DW]: " + message);
String template = plugin.getMsgTemplate(botNick, TemplateName.IRC_DYNMAP_WEB_CHAT);
String rawDWMessage = filterMessage(
Expand All @@ -2264,6 +2281,8 @@ public void broadcastChat(User user, org.pircbotx.Channel channel, String target
String rawNick = nickTmpl.replace("%NICK%", user.getNick());
plugin.dynmapHook.sendMessage(rawNick, rawDWMessage);
messageSent = true;
} else {
plugin.logDebug("Nope, " + TemplateName.IRC_DYNMAP_WEB_CHAT + " is NOT enabled...");
}
}

Expand Down

0 comments on commit dadd45c

Please sign in to comment.