Reload TownyChat if we detect craftIRC perform a reload (no more

unregistered tags after reloading craftIRC).
This commit is contained in:
ElgarL committed 2012-04-21 03:02:37 +01:00
1 parent ab3674345d
commit 436520a183
4 files changed
+41 -7

No files matched your search

+2 -1
View File
@@ -119,4 +119,5 @@ v0.27:
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.
v0.29:
- Fix a duplicating chat issue when relaying via craftIRC.
- Fix a duplicating chat issue when relaying via craftIRC.
- Reload TownyChat if we detect craftIRC perform a reload (no more unregistered tags after reloading craftIRC).
+12 -1
View File
@@ -95,7 +95,18 @@ public class Chat extends JavaPlugin {
configuration = null;
channels = null;
}
/**
* Perform a reload of this plugin.
*/
public void reload() {
onDisable();
onEnable();
}
/**
* Attempt to hook any plugins we want to access.
*/
private void checkPlugins() {
Plugin test;
@@ -110,7 +121,7 @@ public class Chat extends JavaPlugin {
try {
if (Double.valueOf(test.getDescription().getVersion()) >= 3.1) {
craftIRC = (CraftIRC) test;
irc = new CraftIRCHandler(craftIRC, "towny");
irc = new CraftIRCHandler(this, craftIRC, "towny");
} else
getLogger().warning("TownyChat requires CraftIRC version 3.1 or higher to relay chat.");
} catch (NumberFormatException e) {
@@ -36,8 +36,7 @@ public class TownyChatCommand implements CommandExecutor {
}
if (args[0].equalsIgnoreCase("reload")) {
plugin.onDisable();
plugin.onEnable();
plugin.reload();
TownyMessaging.sendMsg(sender, "[TownyChat] Settings reloaded!");
return true;
}
@@ -1,5 +1,10 @@
package com.palmergames.bukkit.TownyChat;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginEnableEvent;
import com.ensifera.animosity.craftirc.BasePoint;
import com.ensifera.animosity.craftirc.CommandEndPoint;
import com.ensifera.animosity.craftirc.CraftIRC;
@@ -46,17 +51,22 @@ import com.palmergames.bukkit.towny.Towny;
*/
public class CraftIRCHandler extends BasePoint implements CommandEndPoint {
Towny plugin;
Towny towny;
Chat plugin;
CraftIRC irc;
public CraftIRCHandler( CraftIRC irc, String tag) {
public CraftIRCHandler(Chat plugin, CraftIRC irc, String tag) {
this.irc = irc;
this.plugin = plugin;
// Register this as the tags endpoint
if (irc != null)
irc.registerEndPoint(tag, this);
// Second argument below is the command name
//irc.registerCommand(tag, tag);
// register a Listen for any restarts of craftIRC
plugin.getServer().getPluginManager().registerEvents(new BukkitEvents(), plugin);
}
@Override
@@ -88,5 +98,18 @@ public class CraftIRCHandler extends BasePoint implements CommandEndPoint {
}
}
protected class BukkitEvents implements Listener {
@EventHandler(priority = EventPriority.NORMAL)
public void onPluginEnable(PluginEnableEvent event) {
if ((irc != null) && (event.getPlugin().equals(irc)))
plugin.reload();
}
}
}
}