diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml old mode 100644 new mode 100755 diff --git a/src/main/java/com/cnaude/purpleirc/Events/VentureChatEvent.java b/src/main/java/com/cnaude/purpleirc/Events/VentureChatEvent.java index 5285a34..18458f9 100644 --- a/src/main/java/com/cnaude/purpleirc/Events/VentureChatEvent.java +++ b/src/main/java/com/cnaude/purpleirc/Events/VentureChatEvent.java @@ -32,15 +32,18 @@ public class VentureChatEvent extends Event { private static final HandlerList HANDLERS = new HandlerList(); private final AsyncPlayerChatEvent event; private final PurpleBot bot; + private final String ircChannel; /** * * @param event * @param bot + * @param ircChannel */ - public VentureChatEvent(AsyncPlayerChatEvent event, PurpleBot bot) { + public VentureChatEvent(AsyncPlayerChatEvent event, PurpleBot bot, String ircChannel) { this.event = event; this.bot = bot; + this.ircChannel = ircChannel; } /** @@ -66,6 +69,14 @@ public class VentureChatEvent extends Event { public PurpleBot getBot() { return bot; } + + /** + * + * @return + */ + public String getIrcChannel() { + return ircChannel; + } /** * diff --git a/src/main/java/com/cnaude/purpleirc/GameListeners/VentureChatListener.java b/src/main/java/com/cnaude/purpleirc/GameListeners/VentureChatListener.java index 003ca9b..29fe393 100644 --- a/src/main/java/com/cnaude/purpleirc/GameListeners/VentureChatListener.java +++ b/src/main/java/com/cnaude/purpleirc/GameListeners/VentureChatListener.java @@ -50,17 +50,19 @@ public class VentureChatListener implements Listener { */ @EventHandler(ignoreCancelled = true, priority = EventPriority.NORMAL) public void onVentureChatEvent(VentureChatEvent event) { - ventureChat(event.getPlayer(), event.getMessage(), event.getBot()); + plugin.logDebug("Entering onVentureChatEvent: " + event.getMessage()); + ventureChat(event.getPlayer(), event.getMessage(), event.getBot(), event.getIrcChannel()); } /** * VentureChat from game to IRC * - * @param player - * @param message + * @param player the player + * @param message the message * @param bot the calling bot + * @param channelName destination IRC channel */ - public void ventureChat(Player player, String message, PurpleBot bot) { + public void ventureChat(Player player, String message, PurpleBot bot, String channelName) { MineverseChatPlayer mcp = MineverseChatAPI.getMineverseChatPlayer(player); ChatChannel eventChannel = mcp.getCurrentChannel(); if (mcp.isQuickChat()) { //for single message chat detection @@ -75,23 +77,21 @@ public class VentureChatListener implements Listener { } String vcChannel = eventChannel.getName(); String vcColor = eventChannel.getColor(); - for (String channelName : bot.botChannels) { - if (!bot.isPlayerInValidWorld(player, channelName)) { - continue; - } - plugin.logDebug("VC Channel: " + vcChannel); - String channelTemplateName = "venture-" + vcChannel + "-chat"; - if (bot.isMessageEnabled(channelName, channelTemplateName) - || bot.isMessageEnabled(channelName, TemplateName.VENTURE_CHAT)) { - String template = plugin.getVentureChatTemplate(bot.botNick, vcChannel); - plugin.logDebug("VC Template: " + template); - bot.asyncIRCMessage(channelName, plugin.tokenizer - .ventureChatTokenizer(player, vcChannel, vcColor, message, template)); - } else { - plugin.logDebug("Player " + player.getName() + " is in VentureChat channel " - + vcChannel + ". Message types " + channelTemplateName + " and " - + TemplateName.VENTURE_CHAT + " are disabled. No message sent to IRC."); - } + if (!bot.isPlayerInValidWorld(player, channelName)) { + return; + } + plugin.logDebug("VC Channel: " + vcChannel); + String channelTemplateName = "venture-" + vcChannel + "-chat"; + if (bot.isMessageEnabled(channelName, channelTemplateName) + || bot.isMessageEnabled(channelName, TemplateName.VENTURE_CHAT)) { + String template = plugin.getVentureChatTemplate(bot.botNick, vcChannel); + plugin.logDebug("VC Template: " + template); + bot.asyncIRCMessage(channelName, plugin.tokenizer + .ventureChatTokenizer(player, vcChannel, vcColor, message, template)); + } else { + plugin.logDebug("Player " + player.getName() + " is in VentureChat channel " + + vcChannel + ". Message types " + channelTemplateName + " and " + + TemplateName.VENTURE_CHAT + " are disabled. No message sent to IRC."); } } diff --git a/src/main/java/com/cnaude/purpleirc/PurpleBot.java b/src/main/java/com/cnaude/purpleirc/PurpleBot.java index ceefbef..65d412d 100644 --- a/src/main/java/com/cnaude/purpleirc/PurpleBot.java +++ b/src/main/java/com/cnaude/purpleirc/PurpleBot.java @@ -1243,7 +1243,8 @@ public final class PurpleBot { plugin.logDebug("No Factions"); } if (plugin.ventureChatEnabled) { - plugin.getServer().getPluginManager().callEvent(new VentureChatEvent(event, this)); + plugin.logDebug("Calling VentureChatEvent: " + event.getMessage()); + plugin.getServer().getPluginManager().callEvent(new VentureChatEvent(event, this, channelName)); } if (isMessageEnabled(channelName, TemplateName.GAME_CHAT)) { asyncIRCMessage(channelName, plugin.tokenizer