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

Commit

Permalink
Ignore private hc messages.
Browse files Browse the repository at this point in the history
  • Loading branch information
cnaude committed May 2, 2016
1 parent e70a4f1 commit 37173b1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Expand Up @@ -18,9 +18,11 @@

import com.cnaude.purpleirc.PurpleBot;
import com.cnaude.purpleirc.PurpleIRC;
import com.dthielke.api.Channel;
import com.dthielke.api.ChatResult;
import com.dthielke.api.Chatter;
import com.dthielke.api.event.ChannelChatEvent;
import com.dthielke.channel.ConversationChannel;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -50,9 +52,18 @@ public HeroChatListener(PurpleIRC plugin) {
@EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL)
public void onChannelChatEvent(ChannelChatEvent event) {
Chatter chatter = event.getChatter();
Channel channel = chatter.getActiveChannel();
if ((channel instanceof ConversationChannel)) {
plugin.logDebug("Ignoring private message: " + chatter.getPrivateMessageFocus() + ":" + event.getMessage());
return;
}
ChatResult result = event.getResult();
plugin.logDebug("HC Format: " + event.getFormat());
plugin.logDebug("HC Result: " + event.getResult());
if (plugin.heroPrivateChatFormat.equals(event.getFormat())) {
plugin.logDebug("HC Private: TRUE");
return;
}

ChatColor chatColor = event.getChannel().getColor();
Player player = chatter.getPlayer();
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/cnaude/purpleirc/PurpleIRC.java
Expand Up @@ -138,6 +138,7 @@ public class PurpleIRC extends JavaPlugin {
defaultGroupSuffix,
customTabPrefix,
heroChatEmoteFormat,
heroPrivateChatFormat,
listFormat,
listSeparator,
listPlayer,
Expand Down Expand Up @@ -1540,6 +1541,7 @@ private void detectHooks() {
logError(ex.getMessage());
}
heroChatEmoteFormat = heroConfig.getString("format.emote", "");
heroPrivateChatFormat = heroConfig.getString("format.private-message");
} else {
hookList.add(hookFormat(PL_HEROCHAT, false));
}
Expand Down

0 comments on commit 37173b1

Please sign in to comment.