0.29.2 - Fix config caching
This commit is contained in:
parent
c681a9284a
commit
aadba68e83
3 changed files with 6 additions and 3 deletions
2
pom.xml
2
pom.xml
|
|
@ -2,7 +2,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>org.dynmap</groupId>
|
<groupId>org.dynmap</groupId>
|
||||||
<artifactId>dynmap</artifactId>
|
<artifactId>dynmap</artifactId>
|
||||||
<version>0.30</version>
|
<version>0.29.2</version>
|
||||||
<name>dynmap</name>
|
<name>dynmap</name>
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@ import org.json.simple.JSONObject;
|
||||||
public class ClientConfigurationHandler implements HttpHandler {
|
public class ClientConfigurationHandler implements HttpHandler {
|
||||||
private DynmapPlugin plugin;
|
private DynmapPlugin plugin;
|
||||||
private byte[] cachedConfiguration = null;
|
private byte[] cachedConfiguration = null;
|
||||||
|
private int cached_config_hashcode = 0;
|
||||||
|
|
||||||
public ClientConfigurationHandler(DynmapPlugin plugin) {
|
public ClientConfigurationHandler(DynmapPlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
plugin.events.addListener("worldactivated", new Event.Listener<DynmapWorld>() {
|
plugin.events.addListener("worldactivated", new Event.Listener<DynmapWorld>() {
|
||||||
|
|
@ -25,13 +27,14 @@ public class ClientConfigurationHandler implements HttpHandler {
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void handle(String path, HttpRequest request, HttpResponse response) throws Exception {
|
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();
|
JSONObject configurationObject = new JSONObject();
|
||||||
plugin.events.<JSONObject>trigger("buildclientconfiguration", configurationObject);
|
plugin.events.<JSONObject>trigger("buildclientconfiguration", configurationObject);
|
||||||
|
|
||||||
String s = configurationObject.toJSONString();
|
String s = configurationObject.toJSONString();
|
||||||
|
|
||||||
cachedConfiguration = s.getBytes("UTF-8");
|
cachedConfiguration = s.getBytes("UTF-8");
|
||||||
|
cached_config_hashcode = plugin.getConfigHashcode();
|
||||||
}
|
}
|
||||||
String dateStr = new Date().toString();
|
String dateStr = new Date().toString();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
var config = {
|
var config = {
|
||||||
// For internal server or proxying webserver.
|
// For internal server or proxying webserver.
|
||||||
url : {
|
url : {
|
||||||
configuration : 'up/configuration?_={timestamp}',
|
configuration : 'up/configuration',
|
||||||
update : 'up/world/{world}/{timestamp}',
|
update : 'up/world/{world}/{timestamp}',
|
||||||
sendmessage : 'up/sendmessage'
|
sendmessage : 'up/sendmessage'
|
||||||
},
|
},
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue