mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-25 18:17:37 +01:00
Moved HeroChat code to HeroWebChatModule.
This commit is contained in:
parent
b2cb15b75c
commit
987e6bcb54
@ -2,6 +2,15 @@
|
||||
|
||||
components:
|
||||
- class: org.dynmap.ClientConfigurationComponent
|
||||
- class: org.dynmap.SimpleWebChatComponent
|
||||
#- class: org.dynmap.herochat.HeroWebChatComponent
|
||||
# # Control which HeroChat channel messages from web are directed to
|
||||
# herochatwebchannel: Global
|
||||
# # Control which channels are monitored and reported to the web
|
||||
# herochatchannels:
|
||||
# - Global
|
||||
# #- Trade
|
||||
# #- Haggle
|
||||
- class: org.dynmap.ClientComponent
|
||||
type: chat
|
||||
- class: org.dynmap.ClientComponent
|
||||
@ -90,15 +99,6 @@ updaterate: 2000
|
||||
allowchat: true
|
||||
allowwebchat: true
|
||||
webchat-interval: 5
|
||||
# Set to true to enable HeroChat support
|
||||
enableherochat: false
|
||||
# Control which HeroChat channel messages from web are directed to
|
||||
herochatwebchannel: Global
|
||||
# Control which channels are monitored and reported to the web
|
||||
herochatchannels:
|
||||
- Global
|
||||
#- Trade
|
||||
#- Haggle
|
||||
|
||||
showplayerfacesinmenu: true
|
||||
|
||||
|
12
src/main/java/org/dynmap/ChatEvent.java
Normal file
12
src/main/java/org/dynmap/ChatEvent.java
Normal file
@ -0,0 +1,12 @@
|
||||
package org.dynmap;
|
||||
|
||||
public class ChatEvent {
|
||||
public String source;
|
||||
public String name;
|
||||
public String message;
|
||||
public ChatEvent(String source, String name, String message) {
|
||||
this.source = source;
|
||||
this.name = name;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
@ -19,9 +19,6 @@ public class ClientConfigurationComponent extends Component {
|
||||
s(t, "allowchat", c.getBoolean("allowchat", true));
|
||||
s(t, "allowwebchat", c.getBoolean("allowwebchat", true));
|
||||
s(t, "webchat-interval", c.getFloat("webchat-interval", 5.0f));
|
||||
s(t, "enableherochat", c.getBoolean("enableherochat", false));
|
||||
s(t, "herochatwebchannel", c.getString("herochatwebchannel", "Global"));
|
||||
s(t, "herochatchannels", l(c.getStrings("herochatchannels", null)));
|
||||
s(t, "showplayerfacesinmenu", c.getBoolean("showplayerfacesinmenu", true));
|
||||
s(t, "joinmessage", c.getString("joinmessage", "%playername% joined"));
|
||||
s(t, "quitmessage", c.getString("joinmessage", "%playername% quit"));
|
||||
|
@ -54,7 +54,6 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
public ConfigurationNode configuration;
|
||||
public HashSet<String> enabledTriggers = new HashSet<String>();
|
||||
public PermissionProvider permissions;
|
||||
public HeroChatHandler hchand;
|
||||
public ComponentManager componentManager = new ComponentManager();
|
||||
public Events events = new Events();
|
||||
|
||||
@ -106,8 +105,6 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
timer.scheduleAtFixedRate(new JsonTimerTask(this, configuration), jsonInterval, jsonInterval);
|
||||
}
|
||||
|
||||
hchand = new HeroChatHandler(configuration, this, getServer());
|
||||
|
||||
enabledTriggers.clear();
|
||||
List<String> triggers = configuration.getStrings("render-triggers", new ArrayList<String>());
|
||||
if (triggers != null)
|
||||
@ -415,8 +412,7 @@ public class DynmapPlugin extends JavaPlugin {
|
||||
public void webChat(String name, String message) {
|
||||
mapManager.pushUpdate(new Client.ChatMessage("web", null, name, message, null));
|
||||
Log.info("[WEB]" + name + ": " + message);
|
||||
/* Let HeroChat take a look - only broadcast to players if it doesn't handle it */
|
||||
if(hchand.sendWebMessageToHeroChat(name, message) == false)
|
||||
getServer().broadcastMessage("[WEB]" + name + ": " + message);
|
||||
ChatEvent event = new ChatEvent("web", name, message);
|
||||
events.trigger("webchat", event);
|
||||
}
|
||||
}
|
||||
|
15
src/main/java/org/dynmap/SimpleWebChatComponent.java
Normal file
15
src/main/java/org/dynmap/SimpleWebChatComponent.java
Normal file
@ -0,0 +1,15 @@
|
||||
package org.dynmap;
|
||||
|
||||
public class SimpleWebChatComponent extends Component {
|
||||
|
||||
public SimpleWebChatComponent(final DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
plugin.events.addListener("webchat", new Event.Listener<ChatEvent>() {
|
||||
@Override
|
||||
public void triggered(ChatEvent t) {
|
||||
plugin.getServer().broadcastMessage("[WEB]" + t.name + ": " + t.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package org.dynmap;
|
||||
package org.dynmap.herochat;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Collections;
|
||||
@ -11,6 +11,11 @@ import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import java.lang.reflect.Field;
|
||||
import org.dynmap.Client;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapPlugin;
|
||||
import org.dynmap.Log;
|
||||
import org.dynmap.Client.ChatMessage;
|
||||
|
||||
public class HeroChatHandler {
|
||||
private static final String DEF_CHANNEL = "Global";
|
||||
@ -239,22 +244,20 @@ public class HeroChatHandler {
|
||||
|
||||
public HeroChatHandler(ConfigurationNode cfg, DynmapPlugin plugin, Server server) {
|
||||
/* If we're enabling hero chat support */
|
||||
if (cfg.getBoolean("enableherochat", false)) {
|
||||
Log.info("HeroChat support configured");
|
||||
this.plugin = plugin;
|
||||
/* Now, get the monitored channel list */
|
||||
hcchannels = cfg.getStrings("herochatchannels", DEF_CHANNELS);
|
||||
/* And get channel to send web messages */
|
||||
hcwebinputchannel = cfg.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);
|
||||
}
|
||||
Log.info("HeroChat support configured");
|
||||
this.plugin = plugin;
|
||||
/* Now, get the monitored channel list */
|
||||
hcchannels = cfg.getStrings("herochatchannels", DEF_CHANNELS);
|
||||
/* And get channel to send web messages */
|
||||
hcwebinputchannel = cfg.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);
|
||||
}
|
||||
}
|
||||
|
25
src/main/java/org/dynmap/herochat/HeroWebChatComponent.java
Normal file
25
src/main/java/org/dynmap/herochat/HeroWebChatComponent.java
Normal file
@ -0,0 +1,25 @@
|
||||
package org.dynmap.herochat;
|
||||
|
||||
import org.dynmap.ChatEvent;
|
||||
import org.dynmap.Component;
|
||||
import org.dynmap.ConfigurationNode;
|
||||
import org.dynmap.DynmapPlugin;
|
||||
import org.dynmap.Event;
|
||||
|
||||
public class HeroWebChatComponent extends Component {
|
||||
HeroChatHandler handler;
|
||||
public HeroWebChatComponent(final DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
handler = new HeroChatHandler(configuration, plugin, plugin.getServer());
|
||||
plugin.events.addListener("webchat", new Event.Listener<ChatEvent>() {
|
||||
@Override
|
||||
public void triggered(ChatEvent t) {
|
||||
/* Let HeroChat take a look - only broadcast to players if it doesn't handle it */
|
||||
if (!handler.sendWebMessageToHeroChat(t.name, t.message)) {
|
||||
plugin.getServer().broadcastMessage("[WEB]" + t.name + ": " + t.message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user