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
50
src/main/java/org/dynmap/ClientComponent.java
Normal file
50
src/main/java/org/dynmap/ClientComponent.java
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
package org.dynmap;
|
||||
|
||||
import static org.dynmap.JSONUtils.a;
|
||||
import static org.dynmap.JSONUtils.s;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
public class ClientComponent extends Component {
|
||||
|
||||
public ClientComponent(final DynmapPlugin plugin, final ConfigurationNode configuration) {
|
||||
super(plugin, configuration);
|
||||
plugin.events.addListener("buildclientconfiguration", new Event.Listener<JSONObject>() {
|
||||
@Override
|
||||
public void triggered(JSONObject t) {
|
||||
JSONObject o = convertMap(configuration);
|
||||
o.remove("class");
|
||||
a(t, "components", o);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
JSONObject convertMap(Map<String, ?> m) {
|
||||
JSONObject o = new JSONObject();
|
||||
for(Map.Entry<String, ?> entry : m.entrySet()) {
|
||||
s(o, entry.getKey(), convert(entry.getValue()));
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
JSONArray convertList(List<?> l) {
|
||||
JSONArray o = new JSONArray();
|
||||
for(Object entry : l) {
|
||||
o.add(convert(entry));
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
Object convert(Object o) {
|
||||
if (o instanceof Map<?, ?>) {
|
||||
return convertMap((Map<String, ?>)o);
|
||||
} else if (o instanceof List<?>) {
|
||||
return convertList((List<?>)o);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -20,8 +20,6 @@ import org.bukkit.World;
|
|||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
|
|
@ -45,8 +43,8 @@ import org.dynmap.web.Json;
|
|||
import org.dynmap.web.handlers.ClientConfigurationHandler;
|
||||
import org.dynmap.web.handlers.ClientUpdateHandler;
|
||||
import org.dynmap.web.handlers.FilesystemHandler;
|
||||
import org.dynmap.web.handlers.SendMessageHandler;
|
||||
import org.dynmap.web.handlers.RegionHandler;
|
||||
import org.dynmap.web.handlers.SendMessageHandler;
|
||||
|
||||
public class DynmapPlugin extends JavaPlugin {
|
||||
public HttpServer webServer = null;
|
||||
|
|
@ -57,6 +55,7 @@ public class DynmapPlugin extends JavaPlugin {
|
|||
public PermissionProvider permissions;
|
||||
public HeroChatHandler hchand;
|
||||
public ComponentManager componentManager = new ComponentManager();
|
||||
public Events events = new Events();
|
||||
|
||||
public Timer timer;
|
||||
|
||||
|
|
@ -70,7 +69,7 @@ public class DynmapPlugin extends JavaPlugin {
|
|||
public HttpServer getWebServer() {
|
||||
return webServer;
|
||||
}
|
||||
|
||||
|
||||
public void onEnable() {
|
||||
permissions = NijikokunPermissions.create(getServer(), "dynmap");
|
||||
if (permissions == null)
|
||||
|
|
@ -83,7 +82,7 @@ public class DynmapPlugin extends JavaPlugin {
|
|||
configuration = new ConfigurationNode(bukkitConfiguration);
|
||||
|
||||
loadDebuggers();
|
||||
|
||||
|
||||
// Load components.
|
||||
for(Component component : configuration.<Component>createInstances("components", new Class<?>[] { DynmapPlugin.class }, new Object[] { this })) {
|
||||
componentManager.add(component);
|
||||
|
|
@ -147,7 +146,7 @@ public class DynmapPlugin extends JavaPlugin {
|
|||
webServer.handlers.put("/", new FilesystemHandler(getFile(configuration.getString("webpath", "web"))));
|
||||
webServer.handlers.put("/tiles/", new FilesystemHandler(tilesDirectory));
|
||||
webServer.handlers.put("/up/", new ClientUpdateHandler(mapManager, playerList, getServer(), configuration.getBoolean("health-in-json", false)));
|
||||
webServer.handlers.put("/up/configuration", new ClientConfigurationHandler(configuration.getNode("web")));
|
||||
webServer.handlers.put("/up/configuration", new ClientConfigurationHandler(this, configuration.getNode("web")));
|
||||
/* See if regions configuration branch is present */
|
||||
for(ConfigurationNode type : configuration.getNodes("web/components")) {
|
||||
if(type.getString("type").equalsIgnoreCase("regions")) {
|
||||
|
|
@ -217,9 +216,9 @@ public class DynmapPlugin extends JavaPlugin {
|
|||
}
|
||||
};
|
||||
if (isTrigger("blockplaced"))
|
||||
pm.registerEvent(Event.Type.BLOCK_PLACE, renderTrigger, Priority.Monitor, this);
|
||||
pm.registerEvent(org.bukkit.event.Event.Type.BLOCK_PLACE, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this);
|
||||
if (isTrigger("blockbreak"))
|
||||
pm.registerEvent(Event.Type.BLOCK_BREAK, renderTrigger, Priority.Monitor, this);
|
||||
pm.registerEvent(org.bukkit.event.Event.Type.BLOCK_BREAK, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this);
|
||||
}
|
||||
{
|
||||
PlayerListener renderTrigger = new PlayerListener() {
|
||||
|
|
@ -234,9 +233,9 @@ public class DynmapPlugin extends JavaPlugin {
|
|||
}
|
||||
};
|
||||
if (isTrigger("playerjoin"))
|
||||
pm.registerEvent(Event.Type.PLAYER_JOIN, renderTrigger, Priority.Monitor, this);
|
||||
pm.registerEvent(org.bukkit.event.Event.Type.PLAYER_JOIN, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this);
|
||||
if (isTrigger("playermove"))
|
||||
pm.registerEvent(Event.Type.PLAYER_MOVE, renderTrigger, Priority.Monitor, this);
|
||||
pm.registerEvent(org.bukkit.event.Event.Type.PLAYER_MOVE, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this);
|
||||
}
|
||||
{
|
||||
WorldListener renderTrigger = new WorldListener() {
|
||||
|
|
@ -255,7 +254,7 @@ public class DynmapPlugin extends JavaPlugin {
|
|||
*/
|
||||
};
|
||||
if (isTrigger("chunkloaded"))
|
||||
pm.registerEvent(Event.Type.CHUNK_LOAD, renderTrigger, Priority.Monitor, this);
|
||||
pm.registerEvent(org.bukkit.event.Event.Type.CHUNK_LOAD, renderTrigger, org.bukkit.event.Event.Priority.Monitor, this);
|
||||
//if (isTrigger("chunkgenerated")) pm.registerEvent(Event.Type.CHUNK_GENERATED, renderTrigger, Priority.Monitor, this);
|
||||
}
|
||||
|
||||
|
|
@ -264,10 +263,10 @@ public class DynmapPlugin extends JavaPlugin {
|
|||
// To handle webchat.
|
||||
PlayerListener playerListener = new DynmapPlayerChatListener(this);
|
||||
//getServer().getPluginManager().registerEvent(Event.Type.PLAYER_COMMAND, playerListener, Priority.Normal, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_CHAT, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_LOGIN, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_QUIT, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(org.bukkit.event.Event.Type.PLAYER_CHAT, playerListener, org.bukkit.event.Event.Priority.Monitor, this);
|
||||
pm.registerEvent(org.bukkit.event.Event.Type.PLAYER_LOGIN, playerListener, org.bukkit.event.Event.Priority.Monitor, this);
|
||||
pm.registerEvent(org.bukkit.event.Event.Type.PLAYER_JOIN, playerListener, org.bukkit.event.Event.Priority.Monitor, this);
|
||||
pm.registerEvent(org.bukkit.event.Event.Type.PLAYER_QUIT, playerListener, org.bukkit.event.Event.Priority.Monitor, this);
|
||||
}
|
||||
|
||||
// To link configuration to real loaded worlds.
|
||||
|
|
@ -277,7 +276,7 @@ public class DynmapPlugin extends JavaPlugin {
|
|||
mm.activateWorld(event.getWorld());
|
||||
}
|
||||
};
|
||||
pm.registerEvent(Event.Type.WORLD_LOAD, worldListener, Priority.Monitor, this);
|
||||
pm.registerEvent(org.bukkit.event.Event.Type.WORLD_LOAD, worldListener, org.bukkit.event.Event.Priority.Monitor, this);
|
||||
}
|
||||
|
||||
private static File combinePaths(File parent, String path) {
|
||||
|
|
|
|||
34
src/main/java/org/dynmap/Events.java
Normal file
34
src/main/java/org/dynmap/Events.java
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package org.dynmap;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
public class Events {
|
||||
public Map<String, Event<?>> events = new HashMap<String, Event<?>>();
|
||||
public <T> void addListener(String eventName, Event.Listener<T> listener) {
|
||||
Event<?> genericEvent = events.get(eventName);
|
||||
Event<T> event = null;
|
||||
if (genericEvent != null) {
|
||||
event = (Event<T>)genericEvent;
|
||||
} else {
|
||||
events.put(eventName, event = new Event<T>());
|
||||
}
|
||||
event.addListener(listener);
|
||||
}
|
||||
|
||||
public <T> void removeListener(String eventName, Event.Listener<T> listener) {
|
||||
Event<?> genericEvent = events.get(eventName);
|
||||
Event<T> event = null;
|
||||
if (genericEvent != null) {
|
||||
event = (Event<T>)genericEvent;
|
||||
event.removeListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void trigger(String eventName, T argument) {
|
||||
Event<?> genericEvent = events.get(eventName);
|
||||
if (genericEvent == null)
|
||||
return;
|
||||
((Event<T>)genericEvent).trigger(argument);
|
||||
}
|
||||
}
|
||||
68
src/main/java/org/dynmap/JSONUtils.java
Normal file
68
src/main/java/org/dynmap/JSONUtils.java
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
package org.dynmap;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class JSONUtils {
|
||||
|
||||
// Gets a value at the specified path.
|
||||
public static Object g(JSONObject o, String path) {
|
||||
int index = path.indexOf('/');
|
||||
if (index == -1) {
|
||||
return o.get(path);
|
||||
} else {
|
||||
String key = path.substring(0, index);
|
||||
String subpath = path.substring(index+1);
|
||||
Object oo = o.get(key);
|
||||
JSONObject subobject;
|
||||
if (oo == null) {
|
||||
return null;
|
||||
} else /*if (oo instanceof JSONObject)*/ {
|
||||
subobject = (JSONObject)o;
|
||||
}
|
||||
return g(subobject, subpath);
|
||||
}
|
||||
}
|
||||
|
||||
// Sets a value on the specified path. If JSONObjects inside the path are missing, they'll be created.
|
||||
public static void s(JSONObject o, String path, Object value) {
|
||||
int index = path.indexOf('/');
|
||||
if (index == -1) {
|
||||
o.put(path, value);
|
||||
} else {
|
||||
String key = path.substring(0, index);
|
||||
String subpath = path.substring(index+1);
|
||||
Object oo = o.get(key);
|
||||
JSONObject subobject;
|
||||
if (oo == null) {
|
||||
subobject = new JSONObject();
|
||||
o.put(key, subobject);
|
||||
} else /*if (oo instanceof JSONObject)*/ {
|
||||
subobject = (JSONObject)oo;
|
||||
}
|
||||
s(subobject, subpath, value);
|
||||
}
|
||||
}
|
||||
|
||||
// Adds a value to the list at the specified path. If the list does not exist, it will be created.
|
||||
public static void a(JSONObject o, String path, Object value) {
|
||||
Object oo = g(o, path);
|
||||
JSONArray array;
|
||||
if (oo == null) {
|
||||
array =new JSONArray();
|
||||
s(o, path, array);
|
||||
} else {
|
||||
array = (JSONArray)oo;
|
||||
}
|
||||
array.add(value);
|
||||
}
|
||||
|
||||
// Simply creates a JSONArray.
|
||||
public static JSONArray l(Object... items) {
|
||||
JSONArray arr = new JSONArray();
|
||||
for(Object item : items) {
|
||||
arr.add(item);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
|
|
@ -34,6 +34,14 @@ public class MapManager {
|
|||
Runnable run;
|
||||
}
|
||||
|
||||
public DynmapWorld getWorld(String name) {
|
||||
DynmapWorld world = worlds.get(name);
|
||||
if(world == null) {
|
||||
world = inactiveworlds.get(name);
|
||||
}
|
||||
return world;
|
||||
}
|
||||
|
||||
private class FullWorldRenderState implements Runnable {
|
||||
DynmapWorld world; /* Which world are we rendering */
|
||||
Location loc; /* Start location */
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ package org.dynmap;
|
|||
import java.io.File;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public abstract class MapType {
|
||||
public Event<MapTile> onTileInvalidated = new Event<MapTile>();
|
||||
|
|
@ -14,4 +15,7 @@ public abstract class MapType {
|
|||
public abstract DynmapChunk[] getRequiredChunks(MapTile tile);
|
||||
|
||||
public abstract boolean render(MapChunkCache cache, MapTile tile, File outputFile);
|
||||
|
||||
public void buildClientConfiguration(JSONObject worldObject) {
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package org.dynmap.flat;
|
||||
|
||||
import static org.dynmap.JSONUtils.a;
|
||||
import static org.dynmap.JSONUtils.s;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.io.File;
|
||||
|
|
@ -21,13 +24,16 @@ import org.dynmap.MapType;
|
|||
import org.dynmap.debug.Debug;
|
||||
import org.dynmap.kzedmap.KzedMap;
|
||||
import org.dynmap.MapChunkCache;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class FlatMap extends MapType {
|
||||
private ConfigurationNode configuration;
|
||||
private String prefix;
|
||||
private ColorScheme colorScheme;
|
||||
private int maximumHeight = 127;
|
||||
|
||||
public FlatMap(ConfigurationNode configuration) {
|
||||
this.configuration = configuration;
|
||||
prefix = (String) configuration.get("prefix");
|
||||
colorScheme = ColorScheme.getScheme((String) configuration.get("colorscheme"));
|
||||
Object o = configuration.get("maximumheight");
|
||||
|
|
@ -206,4 +212,15 @@ public class FlatMap extends MapType {
|
|||
return map.prefix + "_" + size + "_" + -(y+1) + "_" + x + ".png";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildClientConfiguration(JSONObject worldObject) {
|
||||
ConfigurationNode c = configuration;
|
||||
JSONObject o = new JSONObject();
|
||||
s(o, "type", "FlatMapType");
|
||||
s(o, "name", c.getString("name"));
|
||||
s(o, "title", c.getString("title"));
|
||||
s(o, "prefix", c.getString("prefix"));
|
||||
a(worldObject, "maps", o);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
package org.dynmap.kzedmap;
|
||||
|
||||
import static org.dynmap.JSONUtils.a;
|
||||
import static org.dynmap.JSONUtils.s;
|
||||
|
||||
import java.awt.Graphics2D;
|
||||
import java.awt.RenderingHints;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.awt.image.WritableRaster;
|
||||
import java.io.File;
|
||||
|
|
@ -17,10 +22,12 @@ import org.dynmap.ConfigurationNode;
|
|||
import org.dynmap.MapManager;
|
||||
import org.dynmap.debug.Debug;
|
||||
import org.dynmap.MapChunkCache;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class DefaultTileRenderer implements MapTileRenderer {
|
||||
protected static final Color translucent = new Color(0, 0, 0, 0);
|
||||
protected String name;
|
||||
protected ConfigurationNode configuration;
|
||||
protected int maximumHeight = 127;
|
||||
protected ColorScheme colorScheme;
|
||||
|
||||
|
|
@ -34,6 +41,7 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||
}
|
||||
|
||||
public DefaultTileRenderer(ConfigurationNode configuration) {
|
||||
this.configuration = configuration;
|
||||
name = (String) configuration.get("prefix");
|
||||
Object o = configuration.get("maximumheight");
|
||||
if (o != null) {
|
||||
|
|
@ -356,4 +364,15 @@ public class DefaultTileRenderer implements MapTileRenderer {
|
|||
c.setRGBA((c.getRed() * scale) >> 8, (c.getGreen() * scale) >> 8,
|
||||
(c.getBlue() * scale) >> 8, c.getAlpha());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildClientConfiguration(JSONObject worldObject) {
|
||||
ConfigurationNode c = configuration;
|
||||
JSONObject o = new JSONObject();
|
||||
s(o, "type", "KzedMapType");
|
||||
s(o, "name", c.getString("name"));
|
||||
s(o, "title", c.getString("title"));
|
||||
s(o, "prefix", c.getString("prefix"));
|
||||
a(worldObject, "maps", o);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import org.dynmap.Log;
|
|||
import org.dynmap.MapTile;
|
||||
import org.dynmap.MapType;
|
||||
import org.dynmap.MapChunkCache;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class KzedMap extends MapType {
|
||||
protected static final Logger log = Logger.getLogger("Minecraft");
|
||||
|
|
@ -300,4 +301,11 @@ public class KzedMap extends MapType {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildClientConfiguration(JSONObject worldObject) {
|
||||
for(MapTileRenderer renderer : renderers) {
|
||||
renderer.buildClientConfiguration(worldObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,8 +3,12 @@ package org.dynmap.kzedmap;
|
|||
import java.io.File;
|
||||
import org.dynmap.MapChunkCache;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public interface MapTileRenderer {
|
||||
String getName();
|
||||
|
||||
boolean render(MapChunkCache cache, KzedMapTile tile, File outputFile);
|
||||
|
||||
void buildClientConfiguration(JSONObject worldObject);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,22 +4,28 @@ import java.io.BufferedOutputStream;
|
|||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.dynmap.DynmapPlugin;
|
||||
import org.dynmap.web.HttpHandler;
|
||||
import org.dynmap.web.HttpRequest;
|
||||
import org.dynmap.web.HttpResponse;
|
||||
import org.dynmap.web.HttpStatus;
|
||||
import org.dynmap.web.Json;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class ClientConfigurationHandler implements HttpHandler {
|
||||
private DynmapPlugin plugin;
|
||||
private Map<?, ?> configuration;
|
||||
private byte[] cachedConfiguration = null;
|
||||
public ClientConfigurationHandler(Map<?, ?> configuration) {
|
||||
public ClientConfigurationHandler(DynmapPlugin plugin, Map<?, ?> configuration) {
|
||||
this.plugin = plugin;
|
||||
this.configuration = configuration;
|
||||
}
|
||||
@Override
|
||||
public void handle(String path, HttpRequest request, HttpResponse response) throws Exception {
|
||||
if (cachedConfiguration == null) {
|
||||
String s = Json.stringifyJson(configuration);
|
||||
JSONObject configurationObject = new JSONObject();
|
||||
plugin.events.<JSONObject>trigger("buildclientconfiguration", configurationObject);
|
||||
|
||||
String s = configurationObject.toJSONString();
|
||||
|
||||
cachedConfiguration = s.getBytes();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue