From 6c8f030d499c8f9e57811f003d003f61c63bdab9 Mon Sep 17 00:00:00 2001 From: ElgarL Date: Fri, 20 Apr 2012 22:24:28 +0100 Subject: [PATCH] Fix a duplicating chat issue when relaying via craftIRC. --- src/changelog.txt | 4 +- .../palmergames/bukkit/TownyChat/Chat.java | 24 ++++++++---- .../bukkit/TownyChat/CraftIRCHandler.java | 37 +++++++++++++------ src/plugin.yml | 2 +- 4 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/changelog.txt b/src/changelog.txt index ce49be6..292d4e7 100644 --- a/src/changelog.txt +++ b/src/changelog.txt @@ -117,4 +117,6 @@ v0.26: v0.27: - Cancel our own event after all other plugins have had a bash at the formatting. v0.28: - - Forget using any fake events and move to setting recipients. We should now be compatible with just about every other chat modifying plugin there is. \ No newline at end of file + - Forget using any fake events and move to setting recipients. We should now be compatible with just about every other chat modifying plugin there is. +v0.29: + - Fix a duplicating chat issue when relaying via craftIRC. \ No newline at end of file diff --git a/src/com/palmergames/bukkit/TownyChat/Chat.java b/src/com/palmergames/bukkit/TownyChat/Chat.java index f9ee8db..f6853dc 100644 --- a/src/com/palmergames/bukkit/TownyChat/Chat.java +++ b/src/com/palmergames/bukkit/TownyChat/Chat.java @@ -80,15 +80,20 @@ public class Chat extends JavaPlugin { public void onDisable() { unregisterPermissions(); // reset any handles - irc = null; + if (craftIRC != null) { craftIRC.unregisterEndPoint("towny"); craftIRC = null; } + irc = null; + dynMap = null; heroicDeathListener= null; towny = null; pm = null; + + configuration = null; + channels = null; } private void checkPlugins() { @@ -105,7 +110,7 @@ public class Chat extends JavaPlugin { try { if (Double.valueOf(test.getDescription().getVersion()) >= 3.1) { craftIRC = (CraftIRC) test; - irc = new CraftIRCHandler(towny, craftIRC, "towny"); + irc = new CraftIRCHandler(craftIRC, "towny"); } else getLogger().warning("TownyChat requires CraftIRC version 3.1 or higher to relay chat."); } catch (NumberFormatException e) { @@ -132,12 +137,15 @@ public class Chat extends JavaPlugin { } public void registerEvents() { - TownyPlayerListener = new TownyChatPlayerListener(this); - - if (TownyPlayerListener != null) - pm.registerEvents(TownyPlayerListener, this); - if (heroicDeathListener != null) - pm.registerEvents(heroicDeathListener, this); + + if (TownyPlayerListener == null) { + TownyPlayerListener = new TownyChatPlayerListener(this); + + if (TownyPlayerListener != null) + pm.registerEvents(TownyPlayerListener, this); + if (heroicDeathListener != null) + pm.registerEvents(heroicDeathListener, this); + } } diff --git a/src/com/palmergames/bukkit/TownyChat/CraftIRCHandler.java b/src/com/palmergames/bukkit/TownyChat/CraftIRCHandler.java index 0ecff10..a94aebc 100644 --- a/src/com/palmergames/bukkit/TownyChat/CraftIRCHandler.java +++ b/src/com/palmergames/bukkit/TownyChat/CraftIRCHandler.java @@ -16,24 +16,36 @@ import com.palmergames.bukkit.towny.Towny; * Disable Auto paths and add the following to the 'paths:' section */ /* - - source: 'minecraft' - target: 'admin' - formatting: - chat: '%message%' - + Set... + auto-paths: false + + Under channels: + + create your channel... + + - name: '#YourChannel' + password: '' + + #Identifies this channel's endpoint (for the paths: section). + tag: 'admin' + + Under paths: + - source: 'admin' # These are endpoint tags target: 'minecraft' # formatting: chat: '%foreground%[%red%%ircPrefix%%sender%%foreground%] %message%' + + */ -public class CraftIRCHandler extends BasePoint implements CommandEndPoint { +public class CraftIRCHandler extends BasePoint implements CommandEndPoint { Towny plugin; CraftIRC irc; - public CraftIRCHandler(Towny plugin, CraftIRC irc, String tag) { - this.plugin = plugin; + public CraftIRCHandler( CraftIRC irc, String tag) { + this.irc = irc; // Register this as the tags endpoint if (irc != null) @@ -46,10 +58,12 @@ public class CraftIRCHandler extends BasePoint implements CommandEndPoint { public Type getType() { return Type.MINECRAFT; } - + @Override - public void commandIn(RelayedCommand cmd) { - // Do nothing here as we do not process commands from IRC. + public void commandIn(RelayedCommand arg0) { + + // TODO Auto-generated method stub + System.out.print("command"); } /** @@ -69,4 +83,5 @@ public class CraftIRCHandler extends BasePoint implements CommandEndPoint { } } + } \ No newline at end of file diff --git a/src/plugin.yml b/src/plugin.yml index 0b5bca7..3641353 100644 --- a/src/plugin.yml +++ b/src/plugin.yml @@ -1,6 +1,6 @@ name: TownyChat main: com.palmergames.bukkit.TownyChat.Chat -version: 0.28 +version: 0.29 author: ElgarL, Shade, phrstbrn website: http://code.google.com/a/eclipselabs.org/p/towny/ description: >