Better fix for HeroChat - still need herochatwebchannel's channel to

be set to join-messages: true to allow web messages before first
player message in channel.
This commit is contained in:
Mike Primm 2011-05-22 01:53:48 -05:00
parent 06785be5f3
commit de73cd4028

View File

@ -10,6 +10,7 @@ import org.bukkit.event.Event;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.event.server.ServerListener;
import org.bukkit.plugin.Plugin;
import java.lang.reflect.Field;
public class HeroChatHandler {
private static final String DEF_CHANNEL = "Global";
@ -18,8 +19,8 @@ public class HeroChatHandler {
private List<String> hcchannels;
private String hcwebinputchannel;
private HeroChatChannel hcwebinputchan;
private DynmapPlugin plugin;
private HeroChatChannel hcwebinputchan;
private class OurPluginListener extends ServerListener {
@Override
@ -209,14 +210,12 @@ public class HeroChatHandler {
* plugin that may not be present....)
*/
HeroChatChannel c = ce.getChannel();
/* If channel name or nickname matches out web channel, remember it */
if((c != null) && (hcwebinputchannel != null) &&
((c.getName().equals(hcwebinputchannel)) ||
c.getNick().equals(hcwebinputchannel))) {
hcwebinputchan = c;
}
if (ce.isCancelled())
return;
if((hcwebinputchannel != null) && ((hcwebinputchannel.equals(c.getName())) ||
(hcwebinputchannel.equals(c.getNick())))) {
hcwebinputchan = c;
}
if (HeroChatChannelChatEvent.isInstance(event)) {
HeroChatChannelChatEvent cce = new HeroChatChannelChatEvent(
event);
@ -249,11 +248,17 @@ public class HeroChatHandler {
/* And get channel to send web messages */
hcwebinputchannel = cfg.getNode("web").getString(
"herochatwebchannel", DEF_CHANNEL);
Plugin hc = server.getPluginManager().getPlugin("HeroChat");
if(hc != null) {
activateHeroChat(hc);
}
else {
/* Set up to hear when HeroChat is enabled */
server.getPluginManager().registerEvent(Event.Type.PLUGIN_ENABLE,
new OurPluginListener(), Event.Priority.Normal, plugin);
}
}
}
private void activateHeroChat(Plugin herochat) {
if (HeroChatChannelChatEvent.initialize() == false) {
@ -268,7 +273,6 @@ public class HeroChatHandler {
Log.severe("Cannot load HeroChat channel event class!");
return;
}
/* Register event handler */
plugin.getServer().getPluginManager().registerEvent(Event.Type.CUSTOM_EVENT,
new OurEventListener(), Event.Priority.Monitor, plugin);