use of com.djrapitops.plan.storage.database.queries.objects.NewerConfigQuery in project Plan by plan-player-analytics.
the class NetworkSettingManager method updateConfigFromDBIfUpdated.
private void updateConfigFromDBIfUpdated(Database database, ServerUUID serverUUID) {
File configFile = getServerConfigFile(serverUUID);
long lastModified = configFile.exists() ? configFile.lastModified() : -1;
Optional<Config> foundConfig = database.query(new NewerConfigQuery(serverUUID, lastModified));
if (foundConfig.isPresent()) {
try {
Config writing = foundConfig.get();
String serverName = writing.getNode(PluginSettings.SERVER_NAME.getPath()).map(ConfigNode::getString).orElse("Unknown");
new ConfigWriter(configFile.toPath()).write(writing);
logger.info("Config file for server '" + serverName + "' updated in /Plan/serverConfiguration");
addFileToWatchList(watcher, configFile);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
use of com.djrapitops.plan.storage.database.queries.objects.NewerConfigQuery in project Plan by plan-player-analytics.
the class ServerSettingsManager method checkDBForNewConfigSettings.
private void checkDBForNewConfigSettings(Database database) {
File configFile = files.getConfigFile();
long lastModified = configFile.exists() ? configFile.lastModified() : -1;
Optional<ServerUUID> serverUUID = serverInfo.getServerUUIDSafe();
if (!serverUUID.isPresent()) {
return;
}
Optional<Config> foundConfig = database.query(new NewerConfigQuery(serverUUID.get(), lastModified));
if (foundConfig.isPresent()) {
try {
new ConfigWriter(configFile.toPath()).write(foundConfig.get());
logger.info("The Config was updated to match one on the Proxy. Reload for changes to take effect.");
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
Aggregations