Search in sources :

Example 1 with ConfigWriter

use of com.djrapitops.plan.settings.config.ConfigWriter 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);
        }
    }
}
Also used : ConfigWriter(com.djrapitops.plan.settings.config.ConfigWriter) NewerConfigQuery(com.djrapitops.plan.storage.database.queries.objects.NewerConfigQuery) ServerUUID(com.djrapitops.plan.identification.ServerUUID) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Config(com.djrapitops.plan.settings.config.Config) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) WatchedFile(com.djrapitops.plan.settings.upkeep.WatchedFile) File(java.io.File)

Example 2 with ConfigWriter

use of com.djrapitops.plan.settings.config.ConfigWriter in project Plan by plan-player-analytics.

the class StoreConfigTransaction method extractConfigSettingLines.

private String extractConfigSettingLines(Config config) {
    TextStringBuilder configTextBuilder = new TextStringBuilder();
    List<String> lines = new ConfigWriter().createLines(config);
    configTextBuilder.appendWithSeparators(lines, "\n");
    return configTextBuilder.toString();
}
Also used : ConfigWriter(com.djrapitops.plan.settings.config.ConfigWriter) TextStringBuilder(org.apache.commons.text.TextStringBuilder)

Aggregations

ConfigWriter (com.djrapitops.plan.settings.config.ConfigWriter)2 ServerUUID (com.djrapitops.plan.identification.ServerUUID)1 Config (com.djrapitops.plan.settings.config.Config)1 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)1 WatchedFile (com.djrapitops.plan.settings.upkeep.WatchedFile)1 NewerConfigQuery (com.djrapitops.plan.storage.database.queries.objects.NewerConfigQuery)1 File (java.io.File)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 TextStringBuilder (org.apache.commons.text.TextStringBuilder)1