mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-29 05:55:57 +01:00
Add additional full-update intervall and periodically restart file-watchers
This commit is contained in:
parent
be059a108f
commit
6e01b607ac
@ -83,8 +83,6 @@ public class Plugin {
|
||||
private WebServer webServer;
|
||||
|
||||
private Timer daemonTimer;
|
||||
private TimerTask saveTask;
|
||||
private TimerTask metricsTask;
|
||||
|
||||
private Map<String, RegionFileWatchService> regionFileWatchServices;
|
||||
|
||||
@ -212,7 +210,7 @@ public void load() throws IOException, ParseResourceException {
|
||||
daemonTimer = new Timer("BlueMap-Plugin-Daemon-Timer", true);
|
||||
|
||||
//periodically save
|
||||
saveTask = new TimerTask() {
|
||||
TimerTask saveTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
save();
|
||||
@ -220,8 +218,35 @@ public void run() {
|
||||
};
|
||||
daemonTimer.schedule(saveTask, TimeUnit.MINUTES.toMillis(2), TimeUnit.MINUTES.toMillis(2));
|
||||
|
||||
//periodically restart the file-watchers
|
||||
TimerTask fileWatcherRestartTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
regionFileWatchServices.values().forEach(RegionFileWatchService::close);
|
||||
regionFileWatchServices.clear();
|
||||
initFileWatcherTasks();
|
||||
}
|
||||
};
|
||||
daemonTimer.schedule(fileWatcherRestartTask, TimeUnit.HOURS.toMillis(1), TimeUnit.HOURS.toMillis(1));
|
||||
|
||||
//periodically update all (non frozen) maps
|
||||
if (pluginConfig.getFullUpdateIntervalMinutes() > 0) {
|
||||
long fullUpdateTime = TimeUnit.MINUTES.toMillis(pluginConfig.getFullUpdateIntervalMinutes());
|
||||
TimerTask updateAllMapsTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
for (BmMap map : maps.values()) {
|
||||
if (pluginState.getMapState(map).isUpdateEnabled()) {
|
||||
renderManager.scheduleRenderTask(new MapUpdateTask(map));
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
daemonTimer.scheduleAtFixedRate(updateAllMapsTask, fullUpdateTime, fullUpdateTime);
|
||||
}
|
||||
|
||||
//metrics
|
||||
metricsTask = new TimerTask() {
|
||||
TimerTask metricsTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (Plugin.this.serverInterface.isMetricsEnabled(coreConfig.isMetricsEnabled()))
|
||||
@ -232,11 +257,7 @@ public void run() {
|
||||
|
||||
//watch map-changes
|
||||
this.regionFileWatchServices = new HashMap<>();
|
||||
for (BmMap map : maps.values()) {
|
||||
if (pluginState.getMapState(map).isUpdateEnabled()) {
|
||||
startWatchingMap(map);
|
||||
}
|
||||
}
|
||||
initFileWatcherTasks();
|
||||
|
||||
//enable api
|
||||
this.api = new BlueMapAPIImpl(this);
|
||||
@ -269,18 +290,12 @@ public void unload() {
|
||||
skinUpdater = null;
|
||||
|
||||
//stop scheduled threads
|
||||
if (metricsTask != null) metricsTask.cancel();
|
||||
metricsTask = null;
|
||||
if (saveTask != null) saveTask.cancel();
|
||||
saveTask = null;
|
||||
if (daemonTimer != null) daemonTimer.cancel();
|
||||
daemonTimer = null;
|
||||
|
||||
//stop file-watchers
|
||||
if (regionFileWatchServices != null) {
|
||||
for (RegionFileWatchService watcher : regionFileWatchServices.values()) {
|
||||
watcher.close();
|
||||
}
|
||||
regionFileWatchServices.values().forEach(RegionFileWatchService::close);
|
||||
regionFileWatchServices.clear();
|
||||
}
|
||||
regionFileWatchServices = null;
|
||||
@ -415,4 +430,12 @@ public MinecraftVersion getMinecraftVersion() {
|
||||
return minecraftVersion;
|
||||
}
|
||||
|
||||
private void initFileWatcherTasks() {
|
||||
for (BmMap map : maps.values()) {
|
||||
if (pluginState.getMapState(map).isUpdateEnabled()) {
|
||||
startWatchingMap(map);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class PluginConfig {
|
||||
|
||||
@ -37,6 +38,7 @@ public class PluginConfig {
|
||||
private Collection<String> hiddenGameModes = Collections.emptyList();
|
||||
private boolean hideInvisible = false;
|
||||
private boolean hideSneaking = false;
|
||||
private long fullUpdateIntervalMinutes = TimeUnit.HOURS.toMinutes(24);
|
||||
|
||||
public PluginConfig(ConfigurationNode node) {
|
||||
|
||||
@ -59,6 +61,9 @@ public PluginConfig(ConfigurationNode node) {
|
||||
//hideSneaking
|
||||
hideSneaking = node.node("hideSneaking").getBoolean(false);
|
||||
|
||||
//periodic map updates
|
||||
fullUpdateIntervalMinutes = node.node("fullUpdateInterval").getLong(TimeUnit.HOURS.toMinutes(24));
|
||||
|
||||
}
|
||||
|
||||
public boolean isLiveUpdatesEnabled() {
|
||||
@ -81,4 +86,8 @@ public boolean isHideSneaking() {
|
||||
return this.hideSneaking;
|
||||
}
|
||||
|
||||
public long getFullUpdateIntervalMinutes() {
|
||||
return fullUpdateIntervalMinutes;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,3 +3,4 @@ skinDownload: true
|
||||
hiddenGameModes: []
|
||||
hideInvisible: true
|
||||
hideSneaking: false
|
||||
fullUpdateInterval: 1440
|
@ -25,3 +25,8 @@ hideInvisible: true
|
||||
# If this is true, players that are sneaking will be hidden on the map.
|
||||
# Default is false
|
||||
hideSneaking: false
|
||||
|
||||
# The interval in minutes in which a full map-update will be triggered.
|
||||
# This is additionally!! to the normal map-update process (in case that fails to detect any file-changes).
|
||||
# Default is 1440 (24 hours)
|
||||
fullUpdateInterval: 1440
|
||||
|
@ -3,3 +3,4 @@ skinDownload: true
|
||||
hiddenGameModes: []
|
||||
hideInvisible: true
|
||||
hideSneaking: false
|
||||
fullUpdateInterval: 1440
|
@ -25,3 +25,8 @@ hideInvisible: true
|
||||
# If this is true, players that are sneaking will be hidden on the map.
|
||||
# Default is false
|
||||
hideSneaking: false
|
||||
|
||||
# The interval in minutes in which a full map-update will be triggered.
|
||||
# This is additionally!! to the normal map-update process (in case that fails to detect any file-changes).
|
||||
# Default is 1440 (24 hours)
|
||||
fullUpdateInterval: 1440
|
||||
|
@ -3,3 +3,4 @@ skinDownload: true
|
||||
hiddenGameModes: []
|
||||
hideInvisible: true
|
||||
hideSneaking: false
|
||||
fullUpdateInterval: 1440
|
@ -25,3 +25,8 @@ hideInvisible: true
|
||||
# If this is true, players that are sneaking will be hidden on the map.
|
||||
# Default is false
|
||||
hideSneaking: false
|
||||
|
||||
# The interval in minutes in which a full map-update will be triggered.
|
||||
# This is additionally!! to the normal map-update process (in case that fails to detect any file-changes).
|
||||
# Default is 1440 (24 hours)
|
||||
fullUpdateInterval: 1440
|
||||
|
@ -3,3 +3,4 @@ skinDownload: true
|
||||
hiddenGameModes: []
|
||||
hideInvisible: true
|
||||
hideSneaking: false
|
||||
fullUpdateInterval: 1440
|
@ -25,3 +25,8 @@ hideInvisible: true
|
||||
# If this is true, players that are sneaking will be hidden on the map.
|
||||
# Default is false
|
||||
hideSneaking: false
|
||||
|
||||
# The interval in minutes in which a full map-update will be triggered.
|
||||
# This is additionally!! to the normal map-update process (in case that fails to detect any file-changes).
|
||||
# Default is 1440 (24 hours)
|
||||
fullUpdateInterval: 1440
|
||||
|
@ -3,3 +3,4 @@ skinDownload: true
|
||||
hiddenGameModes: []
|
||||
hideInvisible: true
|
||||
hideSneaking: false
|
||||
fullUpdateInterval: 1440
|
@ -25,3 +25,8 @@ hideInvisible: true
|
||||
# If this is true, players that are sneaking will be hidden on the map.
|
||||
# Default is false
|
||||
hideSneaking: false
|
||||
|
||||
# The interval in minutes in which a full map-update will be triggered.
|
||||
# This is additionally!! to the normal map-update process (in case that fails to detect any file-changes).
|
||||
# Default is 1440 (24 hours)
|
||||
fullUpdateInterval: 1440
|
||||
|
@ -3,3 +3,4 @@ skinDownload: true
|
||||
hiddenGameModes: []
|
||||
hideInvisible: true
|
||||
hideSneaking: false
|
||||
fullUpdateInterval: 1440
|
@ -25,3 +25,8 @@ hideInvisible: true
|
||||
# If this is true, players that are sneaking will be hidden on the map.
|
||||
# Default is false
|
||||
hideSneaking: false
|
||||
|
||||
# The interval in minutes in which a full map-update will be triggered.
|
||||
# This is additionally!! to the normal map-update process (in case that fails to detect any file-changes).
|
||||
# Default is 1440 (24 hours)
|
||||
fullUpdateInterval: 1440
|
||||
|
@ -3,3 +3,4 @@ skinDownload: true
|
||||
hiddenGameModes: []
|
||||
hideInvisible: true
|
||||
hideSneaking: false
|
||||
fullUpdateInterval: 1440
|
@ -25,3 +25,8 @@ hideInvisible: true
|
||||
# If this is true, players that are sneaking will be hidden on the map.
|
||||
# Default is false
|
||||
hideSneaking: false
|
||||
|
||||
# The interval in minutes in which a full map-update will be triggered.
|
||||
# This is additionally!! to the normal map-update process (in case that fails to detect any file-changes).
|
||||
# Default is 1440 (24 hours)
|
||||
fullUpdateInterval: 1440
|
||||
|
@ -3,3 +3,4 @@ skinDownload: true
|
||||
hiddenGameModes: []
|
||||
hideInvisible: true
|
||||
hideSneaking: false
|
||||
fullUpdateInterval: 1440
|
@ -25,3 +25,8 @@ hideInvisible: true
|
||||
# If this is true, players that are sneaking will be hidden on the map.
|
||||
# Default is false
|
||||
hideSneaking: false
|
||||
|
||||
# The interval in minutes in which a full map-update will be triggered.
|
||||
# This is additionally!! to the normal map-update process (in case that fails to detect any file-changes).
|
||||
# Default is 1440 (24 hours)
|
||||
fullUpdateInterval: 1440
|
||||
|
@ -3,3 +3,4 @@ skinDownload: false
|
||||
hiddenGameModes: []
|
||||
hideInvisible: true
|
||||
hideSneaking: false
|
||||
fullUpdateInterval: 1440
|
@ -25,3 +25,8 @@ hideInvisible: true
|
||||
# If this is true, players that are sneaking will be hidden on the map.
|
||||
# Default is false
|
||||
hideSneaking: false
|
||||
|
||||
# The interval in minutes in which a full map-update will be triggered.
|
||||
# This is additionally!! to the normal map-update process (in case that fails to detect any file-changes).
|
||||
# Default is 1440 (24 hours)
|
||||
fullUpdateInterval: 1440
|
||||
|
@ -3,3 +3,4 @@ skinDownload: false
|
||||
hiddenGameModes: []
|
||||
hideInvisible: true
|
||||
hideSneaking: false
|
||||
fullUpdateInterval: 1440
|
@ -25,3 +25,8 @@ hideInvisible: true
|
||||
# If this is true, players that are sneaking will be hidden on the map.
|
||||
# Default is false
|
||||
hideSneaking: false
|
||||
|
||||
# The interval in minutes in which a full map-update will be triggered.
|
||||
# This is additionally!! to the normal map-update process (in case that fails to detect any file-changes).
|
||||
# Default is 1440 (24 hours)
|
||||
fullUpdateInterval: 1440
|
||||
|
Loading…
Reference in New Issue
Block a user