mirror of
https://github.com/webbukkit/dynmap.git
synced 2025-04-16 00:47:10 +02:00
0.29.2 - Fix config caching
This commit is contained in:
parent
d7a7ee9c5d
commit
a34ba56716
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.dynmap</groupId>
|
||||
<artifactId>dynmap</artifactId>
|
||||
<version>0.30</version>
|
||||
<version>0.29.2</version>
|
||||
<name>dynmap</name>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -14,6 +14,8 @@ import org.json.simple.JSONObject;
|
||||
public class ClientConfigurationHandler implements HttpHandler {
|
||||
private DynmapPlugin plugin;
|
||||
private byte[] cachedConfiguration = null;
|
||||
private int cached_config_hashcode = 0;
|
||||
|
||||
public ClientConfigurationHandler(DynmapPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
plugin.events.addListener("worldactivated", new Event.Listener<DynmapWorld>() {
|
||||
@ -25,13 +27,14 @@ public class ClientConfigurationHandler implements HttpHandler {
|
||||
}
|
||||
@Override
|
||||
public void handle(String path, HttpRequest request, HttpResponse response) throws Exception {
|
||||
if (cachedConfiguration == null) {
|
||||
if ((cachedConfiguration == null) || (plugin.getConfigHashcode() != cached_config_hashcode)) {
|
||||
JSONObject configurationObject = new JSONObject();
|
||||
plugin.events.<JSONObject>trigger("buildclientconfiguration", configurationObject);
|
||||
|
||||
String s = configurationObject.toJSONString();
|
||||
|
||||
cachedConfiguration = s.getBytes("UTF-8");
|
||||
cached_config_hashcode = plugin.getConfigHashcode();
|
||||
}
|
||||
String dateStr = new Date().toString();
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
var config = {
|
||||
// For internal server or proxying webserver.
|
||||
url : {
|
||||
configuration : 'up/configuration?_={timestamp}',
|
||||
configuration : 'up/configuration',
|
||||
update : 'up/world/{world}/{timestamp}',
|
||||
sendmessage : 'up/sendmessage'
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user