mirror of
https://github.com/darksaid98/TownyChat.git
synced 2026-12-04 14:38:58 +00:00
Reload TownyChat if we detect craftIRC perform a reload (no more
unregistered tags after reloading craftIRC).
This commit is contained in:
1 parent
ab3674345d
commit
436520a183
4 files changed
+39
-5
No files matched your search
@@ -120,3 +120,4 @@ 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.
|
- 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:
|
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).
|
||||||
@@ -96,6 +96,17 @@ public class Chat extends JavaPlugin {
|
|||||||
channels = 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() {
|
private void checkPlugins() {
|
||||||
Plugin test;
|
Plugin test;
|
||||||
|
|
||||||
@@ -110,7 +121,7 @@ public class Chat extends JavaPlugin {
|
|||||||
try {
|
try {
|
||||||
if (Double.valueOf(test.getDescription().getVersion()) >= 3.1) {
|
if (Double.valueOf(test.getDescription().getVersion()) >= 3.1) {
|
||||||
craftIRC = (CraftIRC) test;
|
craftIRC = (CraftIRC) test;
|
||||||
irc = new CraftIRCHandler(craftIRC, "towny");
|
irc = new CraftIRCHandler(this, craftIRC, "towny");
|
||||||
} else
|
} else
|
||||||
getLogger().warning("TownyChat requires CraftIRC version 3.1 or higher to relay chat.");
|
getLogger().warning("TownyChat requires CraftIRC version 3.1 or higher to relay chat.");
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
|||||||
@@ -36,8 +36,7 @@ public class TownyChatCommand implements CommandExecutor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args[0].equalsIgnoreCase("reload")) {
|
if (args[0].equalsIgnoreCase("reload")) {
|
||||||
plugin.onDisable();
|
plugin.reload();
|
||||||
plugin.onEnable();
|
|
||||||
TownyMessaging.sendMsg(sender, "[TownyChat] Settings reloaded!");
|
TownyMessaging.sendMsg(sender, "[TownyChat] Settings reloaded!");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
package com.palmergames.bukkit.TownyChat;
|
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.BasePoint;
|
||||||
import com.ensifera.animosity.craftirc.CommandEndPoint;
|
import com.ensifera.animosity.craftirc.CommandEndPoint;
|
||||||
import com.ensifera.animosity.craftirc.CraftIRC;
|
import com.ensifera.animosity.craftirc.CraftIRC;
|
||||||
@@ -46,17 +51,22 @@ import com.palmergames.bukkit.towny.Towny;
|
|||||||
*/
|
*/
|
||||||
public class CraftIRCHandler extends BasePoint implements CommandEndPoint {
|
public class CraftIRCHandler extends BasePoint implements CommandEndPoint {
|
||||||
|
|
||||||
Towny plugin;
|
Towny towny;
|
||||||
|
Chat plugin;
|
||||||
CraftIRC irc;
|
CraftIRC irc;
|
||||||
|
|
||||||
public CraftIRCHandler( CraftIRC irc, String tag) {
|
public CraftIRCHandler(Chat plugin, CraftIRC irc, String tag) {
|
||||||
|
|
||||||
this.irc = irc;
|
this.irc = irc;
|
||||||
|
this.plugin = plugin;
|
||||||
// Register this as the tags endpoint
|
// Register this as the tags endpoint
|
||||||
if (irc != null)
|
if (irc != null)
|
||||||
irc.registerEndPoint(tag, this);
|
irc.registerEndPoint(tag, this);
|
||||||
// Second argument below is the command name
|
// Second argument below is the command name
|
||||||
//irc.registerCommand(tag, tag);
|
//irc.registerCommand(tag, tag);
|
||||||
|
|
||||||
|
// register a Listen for any restarts of craftIRC
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(new BukkitEvents(), plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in new issue
Block a user