package com.github.authme.configme;

import com.github.authme.configme.migration.MigrationService;
import com.github.authme.configme.properties.Property;
import com.github.authme.configme.propertymap.PropertyEntry;
import com.github.authme.configme.resource.PropertyResource;

import java.util.Collections;
import java.util.List;

/**
 * The new settings manager.
 */
public class SettingsManager {

    private final List<PropertyEntry> knownProperties;
    private final PropertyResource resource;
    private final MigrationService migrationService;

    /**
     * Constructor.
     *
     * @param knownProperties collection of all available settings
     * @param resource the property resource to read and write properties to
     * @param migrationService migration service to check the settings file with
     */
    public SettingsManager(List<? extends PropertyEntry> knownProperties, PropertyResource resource,
                           MigrationService migrationService) {
        this.knownProperties = Collections.unmodifiableList(knownProperties);
        this.resource = resource;
        this.migrationService = migrationService;
        validateAndLoadOptions();
    }

    /**
     * Gets the given property from the configuration.
     *
     * @param property The property to retrieve
     * @param <T> The property's type
     * @return The property's value
     */
    public <T> T getProperty(Property<T> property) {
        return property.getValue(resource);
    }

    /**
     * Sets a new value for the given property.
     *
     * @param property The property to modify
     * @param value The new value to assign to the property
     * @param <T> The property's type
     */
    public <T> void setProperty(Property<T> property, T value) {
        resource.setValue(property.getPath(), value);
    }

    /**
     * Reloads the configuration.
     */
    public void reload() {
        resource.reload();
        validateAndLoadOptions();
    }

    /**
     * Saves the config file. Use after migrating one or more settings.
     */
    public void save() {
        resource.exportProperties(knownProperties);
    }

    private void validateAndLoadOptions() {
        if (migrationService.checkAndMigrate(resource, knownProperties)) {
            save();
        }
    }

}

@@ -395,29 +395,31 @@
 er %7B%0A%0A    pr
-ivate
+otected
  final List%3C
@@ -452,29 +452,31 @@
 ties;%0A    pr
-ivate
+otected
  final Prope
@@ -503,21 +503,23 @@
 ;%0A    pr
-ivate
+otected
  final M
@@ -2161,13 +2161,15 @@
   pr
-ivate
+otected
  voi

Set non-public members in SettingsManager to protected instead of private