Added events for components and implemented 'buildclientconfiguration'-event in ClientConfigurationComponent.
This commit is contained in:
parent
38c8254707
commit
e57301b14e
13 changed files with 358 additions and 129 deletions
48
src/main/java/org/dynmap/ClientConfigurationComponent.java
Normal file
48
src/main/java/org/dynmap/ClientConfigurationComponent.java
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package org.dynmap;
|
||||
|
||||
import static org.dynmap.JSONUtils.a;
|
||||
import static org.dynmap.JSONUtils.l;
|
||||
import static org.dynmap.JSONUtils.s;
|
||||
|
||||
import org.dynmap.Event.Listener;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class ClientConfigurationComponent extends Component {
|
||||
public ClientConfigurationComponent(final DynmapPlugin plugin, ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
plugin.events.<JSONObject>addListener("buildclientconfiguration", new Listener<JSONObject>() {
|
||||
@Override
|
||||
public void triggered(JSONObject t) {
|
||||
ConfigurationNode c = plugin.configuration;
|
||||
s(t, "jsonfile", c.getBoolean("jsonfile", false));
|
||||
s(t, "updaterate", c.getFloat("updaterate", 1.0f));
|
||||
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"));
|
||||
s(t, "spammessage", c.getString("joinmessage", "You may only chat once every %interval% seconds."));
|
||||
|
||||
for(ConfigurationNode wn : plugin.configuration.getNodes("worlds")) {
|
||||
DynmapWorld world = plugin.mapManager.getWorld(wn.getString("name"));
|
||||
JSONObject wo = new JSONObject();
|
||||
s(wo, "name", wn.getString("name"));
|
||||
s(wo, "title", wn.getString("title"));
|
||||
s(wo, "center/x", wn.getFloat("center/x", 0.0f));
|
||||
s(wo, "center/y", wn.getFloat("center/y", 0.0f));
|
||||
s(wo, "center/z", wn.getFloat("center/z", 0.0f));
|
||||
a(t, "worlds", wo);
|
||||
|
||||
for(MapType mt : world.maps) {
|
||||
mt.buildClientConfiguration(wo);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue