use of com.djrapitops.plan.settings.config.Config in project Plan by plan-player-analytics.
the class ServerSettingsManager method updateConfigInDB.
private void updateConfigInDB(File file) {
if (!file.exists()) {
return;
}
Database database = dbSystem.getDatabase();
Optional<ServerUUID> serverUUID = serverInfo.getServerUUIDSafe();
if (!serverUUID.isPresent()) {
return;
}
try (ConfigReader reader = new ConfigReader(file.toPath())) {
Config read = reader.read();
database.executeTransaction(new StoreConfigTransaction(serverUUID.get(), read, file.lastModified()));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of com.djrapitops.plan.settings.config.Config 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);
}
}
}
use of com.djrapitops.plan.settings.config.Config in project Plan by plan-player-analytics.
the class DatabaseTest method configIsStoredInTheDatabase.
@Test
default void configIsStoredInTheDatabase() {
PlanConfig config = config();
db().executeTransaction(new StoreConfigTransaction(serverUUID(), config, System.currentTimeMillis()));
Optional<Config> foundConfig = db().query(new NewerConfigQuery(serverUUID(), 0));
assertTrue(foundConfig.isPresent());
assertEquals(config, foundConfig.get());
}
Aggregations