use of com.djrapitops.plan.storage.database.transactions.StoreConfigTransaction 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.storage.database.transactions.StoreConfigTransaction in project Plan by plan-player-analytics.
the class ConfigStoreTask method run.
@Override
public void run() {
long lastModified = files.getConfigFile().lastModified();
dbSystem.getDatabase().executeTransaction(new StoreConfigTransaction(serverInfo.getServerUUID(), config, lastModified));
cancel();
}
use of com.djrapitops.plan.storage.database.transactions.StoreConfigTransaction in project Plan by plan-player-analytics.
the class NetworkSettingManager method updateConfigInDB.
public void updateConfigInDB(File file, ServerUUID serverUUID) {
if (!file.exists()) {
return;
}
Database database = dbSystem.getDatabase();
try (ConfigReader reader = new ConfigReader(file.toPath())) {
Config config = reader.read();
database.executeTransaction(new StoreConfigTransaction(serverUUID, config, file.lastModified()));
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
use of com.djrapitops.plan.storage.database.transactions.StoreConfigTransaction 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());
}
use of com.djrapitops.plan.storage.database.transactions.StoreConfigTransaction in project Plan by plan-player-analytics.
the class DatabaseTest method unchangedConfigDoesNotUpdateInDatabase.
@Test
default void unchangedConfigDoesNotUpdateInDatabase() {
configIsStoredInTheDatabase();
long savedMs = System.currentTimeMillis();
PlanConfig config = config();
db().executeTransaction(new StoreConfigTransaction(serverUUID(), config, System.currentTimeMillis()));
assertFalse(db().query(new NewerConfigQuery(serverUUID(), savedMs)).isPresent());
}
Aggregations