mirror of
https://github.com/webbukkit/dynmap.git
synced 2024-12-01 06:33:38 +01:00
Reduce unneeded multiple saves for persistent marker updates
This commit is contained in:
parent
ca9d26ef99
commit
6fedc7169e
@ -158,17 +158,24 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
|
||||
private boolean stop = false;
|
||||
private Set<String> dirty_worlds = new HashSet<String>();
|
||||
private boolean dirty_markers = false;
|
||||
|
||||
private class DoFileWrites implements Runnable {
|
||||
public void run() {
|
||||
if(stop)
|
||||
return;
|
||||
|
||||
for(String world : dirty_worlds) {
|
||||
writeMarkersFile(world);
|
||||
/* Write markers first - drives JSON updates too */
|
||||
if(dirty_markers) {
|
||||
doSaveMarkers();
|
||||
dirty_markers = false;
|
||||
}
|
||||
/* Process any dirty worlds */
|
||||
if(!dirty_worlds.isEmpty()) {
|
||||
for(String world : dirty_worlds) {
|
||||
writeMarkersFile(world);
|
||||
}
|
||||
dirty_worlds.clear();
|
||||
}
|
||||
dirty_worlds.clear();
|
||||
|
||||
server.getScheduler().scheduleSyncDelayedTask(dynmap, this, 20);
|
||||
}
|
||||
}
|
||||
@ -237,6 +244,11 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
plugin.events.removeListener("worldactivated", api);
|
||||
|
||||
stop = true;
|
||||
if(dirty_markers) {
|
||||
doSaveMarkers();
|
||||
dirty_markers = false;
|
||||
}
|
||||
|
||||
for(MarkerIconImpl icn : markericons.values())
|
||||
icn.cleanup();
|
||||
markericons.clear();
|
||||
@ -375,6 +387,11 @@ public class MarkerAPIImpl implements MarkerAPI, Event.Listener<DynmapWorld> {
|
||||
* Save persistence for markers
|
||||
*/
|
||||
static void saveMarkers() {
|
||||
if(api != null) {
|
||||
api.dirty_markers = true;
|
||||
}
|
||||
}
|
||||
private void doSaveMarkers() {
|
||||
if(api != null) {
|
||||
Configuration conf = new Configuration(api.markerpersist); /* Make configuration object */
|
||||
/* First, save icon definitions */
|
||||
|
Loading…
Reference in New Issue
Block a user