Search in sources :

Example 1 with ConfigReader

use of com.djrapitops.plan.settings.config.ConfigReader 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);
    }
}
Also used : ServerUUID(com.djrapitops.plan.identification.ServerUUID) PlanConfig(com.djrapitops.plan.settings.config.PlanConfig) Config(com.djrapitops.plan.settings.config.Config) ConfigReader(com.djrapitops.plan.settings.config.ConfigReader) Database(com.djrapitops.plan.storage.database.Database) UncheckedIOException(java.io.UncheckedIOException) StoreConfigTransaction(com.djrapitops.plan.storage.database.transactions.StoreConfigTransaction) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException)

Example 2 with ConfigReader

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

the class ThemeConfig method getDefaults.

private static ConfigNode getDefaults(PlanFiles files, PlanConfig config, PluginLogger logger) {
    String fileName = config.get(DisplaySettings.THEME);
    String fileLocation = getFileLocation(fileName);
    try (ConfigReader reader = new ConfigReader(files.getResourceFromJar(fileLocation).asInputStream())) {
        return reader.read();
    } catch (IOException e) {
        logger.error("Could not find theme " + fileLocation + ". Attempting to use default.");
        return new ConfigNode(null, null, null);
    }
}
Also used : ConfigReader(com.djrapitops.plan.settings.config.ConfigReader) IOException(java.io.IOException) ConfigNode(com.djrapitops.plan.settings.config.ConfigNode)

Example 3 with ConfigReader

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

the class ServerFileLoader method prepare.

public void prepare() throws IOException {
    read();
    try (ConfigReader reader = new ConfigReader(files.getResourceFromJar("DefaultServerInfoFile.yml").asInputStream())) {
        copyMissing(reader.read());
    }
    save();
    prepared = true;
}
Also used : ConfigReader(com.djrapitops.plan.settings.config.ConfigReader)

Aggregations

ConfigReader (com.djrapitops.plan.settings.config.ConfigReader)3 IOException (java.io.IOException)2 ServerUUID (com.djrapitops.plan.identification.ServerUUID)1 Config (com.djrapitops.plan.settings.config.Config)1 ConfigNode (com.djrapitops.plan.settings.config.ConfigNode)1 PlanConfig (com.djrapitops.plan.settings.config.PlanConfig)1 Database (com.djrapitops.plan.storage.database.Database)1 StoreConfigTransaction (com.djrapitops.plan.storage.database.transactions.StoreConfigTransaction)1 UncheckedIOException (java.io.UncheckedIOException)1