Search in sources :

Example 1 with ConfigNodes

use of com.palmergames.bukkit.config.ConfigNodes in project Towny by ElgarL.

the class TownySettings method setDefaults.

/**
 * Builds a new config reading old config data.
 */
private static void setDefaults(String version, File file) {
    newConfig = new CommentedConfiguration(file);
    newConfig.load();
    for (ConfigNodes root : ConfigNodes.values()) {
        if (root.getComments().length > 0)
            addComment(root.getRoot(), root.getComments());
        if (root.getRoot() == ConfigNodes.LEVELS.getRoot()) {
            setDefaultLevels();
        } else if ((root.getRoot() == ConfigNodes.LEVELS_TOWN_LEVEL.getRoot()) || (root.getRoot() == ConfigNodes.LEVELS_NATION_LEVEL.getRoot())) {
        // Do nothing here as setDefaultLevels configured town and
        // nation levels.
        } else if (root.getRoot() == ConfigNodes.VERSION.getRoot()) {
            setNewProperty(root.getRoot(), version);
        } else if (root.getRoot() == ConfigNodes.LAST_RUN_VERSION.getRoot()) {
            setNewProperty(root.getRoot(), getLastRunVersion(version));
        } else if (root.getRoot() == ConfigNodes.VERSION_BUKKIT.getRoot()) {
            setNewProperty(root.getRoot(), ConfigNodes.VERSION_BUKKIT.getDefault());
        } else if (root.getRoot() == ConfigNodes.PROT_ITEM_USE_MAT.getRoot()) {
            /*
				 * Update any Id's to Material names (where required).
				 */
            setNewProperty(root.getRoot(), convertIds(getStrArr(ConfigNodes.PROT_ITEM_USE_MAT)));
        } else if (root.getRoot() == ConfigNodes.PROT_SWITCH_MAT.getRoot()) {
            /*
				 * Update any Id's to Material names (where required).
				 */
            setNewProperty(root.getRoot(), convertIds(getStrArr(ConfigNodes.PROT_SWITCH_MAT)));
        } else if (root.getRoot() == ConfigNodes.NWS_PLOT_MANAGEMENT_DELETE.getRoot()) {
            /*
				 * Update any Id's to Material names (where required).
				 */
            setNewProperty(root.getRoot(), convertIds(getStrArr(ConfigNodes.NWS_PLOT_MANAGEMENT_DELETE)));
        } else if (root.getRoot() == ConfigNodes.NWS_PLOT_MANAGEMENT_REVERT_IGNORE.getRoot()) {
            /*
				 * Update any Id's to Material names (where required).
				 */
            setNewProperty(root.getRoot(), convertIds(getStrArr(ConfigNodes.NWS_PLOT_MANAGEMENT_REVERT_IGNORE)));
        } else if (root.getRoot() == ConfigNodes.UNCLAIMED_ZONE_IGNORE.getRoot()) {
            /*
				 * Update any Id's to Material names (where required).
				 */
            setNewProperty(root.getRoot(), convertIds(getStrArr(ConfigNodes.UNCLAIMED_ZONE_IGNORE)));
        } else
            setNewProperty(root.getRoot(), (config.get(root.getRoot().toLowerCase()) != null) ? config.get(root.getRoot().toLowerCase()) : root.getDefault());
    }
    config = newConfig;
    newConfig = null;
}
Also used : CommentedConfiguration(com.palmergames.bukkit.config.CommentedConfiguration) ConfigNodes(com.palmergames.bukkit.config.ConfigNodes)

Aggregations

CommentedConfiguration (com.palmergames.bukkit.config.CommentedConfiguration)1 ConfigNodes (com.palmergames.bukkit.config.ConfigNodes)1