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
|
|
@ -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