mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-11-13 22:05:12 +01:00
Make web UI reload when configuration changes, server restarts
This commit is contained in:
parent
4af95f57df
commit
edcf1cfd10
@ -14,6 +14,7 @@ public class ClientConfigurationComponent extends Component {
|
||||
@Override
|
||||
public void triggered(JSONObject t) {
|
||||
ConfigurationNode c = plugin.configuration;
|
||||
s(t, "confighash", plugin.getConfigHashcode());
|
||||
s(t, "updaterate", c.getFloat("updaterate", 1.0f));
|
||||
s(t, "showplayerfacesinmenu", c.getBoolean("showplayerfacesinmenu", true));
|
||||
s(t, "joinmessage", c.getString("joinmessage", "%playername% joined"));
|
||||
|
@ -35,7 +35,9 @@ public class ClientUpdateComponent extends Component {
|
||||
String worldName = world.getName();
|
||||
int hideifshadow = configuration.getInteger("hideifshadow", 15);
|
||||
int hideifunder = configuration.getInteger("hideifundercover", 15);
|
||||
|
||||
|
||||
s(u, "confighash", plugin.getConfigHashcode());
|
||||
|
||||
s(u, "servertime", world.getTime() % 24000);
|
||||
s(u, "hasStorm", world.hasStorm());
|
||||
s(u, "isThundering", world.isThundering());
|
||||
|
@ -81,6 +81,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
boolean waterbiomeshading = false;
|
||||
boolean fencejoin = false;
|
||||
public CompassMode compassmode = CompassMode.PRE19;
|
||||
private int config_hashcode; /* Used to signal need to reload web configuration (world changes, config update, etc) */
|
||||
|
||||
public enum CompassMode {
|
||||
PRE19, /* Default for 1.8 and earlier (east is Z+) */
|
||||
@ -297,6 +298,8 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
|
||||
playerfacemgr = new PlayerFaces(this);
|
||||
|
||||
updateConfigHashcode(); /* Initialize/update config hashcode */
|
||||
|
||||
loadWebserver();
|
||||
|
||||
enabledTriggers.clear();
|
||||
@ -327,6 +330,14 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
events.<Object>trigger("initialized", null);
|
||||
}
|
||||
|
||||
public void updateConfigHashcode() {
|
||||
config_hashcode = (int)System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public int getConfigHashcode() {
|
||||
return config_hashcode;
|
||||
}
|
||||
|
||||
public void loadWebserver() {
|
||||
InetAddress bindAddress;
|
||||
{
|
||||
@ -633,6 +644,7 @@ public class DynmapPlugin extends JavaPlugin implements DynmapAPI {
|
||||
@Override
|
||||
public void onWorldLoad(WorldLoadEvent event) {
|
||||
mapManager.activateWorld(event.getWorld());
|
||||
updateConfigHashcode();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -526,6 +526,10 @@ DynMap.prototype = {
|
||||
if (!me.options.jsonfile) {
|
||||
me.lasttimestamp = update.timestamp;
|
||||
}
|
||||
if(me.options.confighash != update.confighash) {
|
||||
window.location.reload(true);
|
||||
return;
|
||||
}
|
||||
|
||||
me.servertime = update.servertime;
|
||||
var newserverday = (me.servertime > 23100 || me.servertime < 12900);
|
||||
|
Loading…
Reference in New Issue
Block a user