package sourcecoded.core.configuration;

import java.io.File;

import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;

/**
 * A simplified version of Configuration files
 * with shortcuts to common methods
 *
 * @see net.minecraftforge.common.config.Configuration
 */
public class SourceConfig {

    public Configuration config;

    public File configFile;

    /**
     * Create a new Configuration
     */
    public SourceConfig(File configFile) {
        this.config = new Configuration(configFile);
        this.configFile = configFile;
    }

    /**
     * Load the config from file
     */
    public void loadConfig() {
        config.load();
    }

    /**
     * Save and reload the config
     */
    public void saveConfig() {
        config.save();
        loadConfig();
    }

    /**
     * Get a specified property
     */
    public Property getProperty(String category, String property) {
        return config.getCategory(category).get(property);
    }

    /**
     * Integer
     */
    public Property createProperty(String category, String name, int def) {
        return config.get(category, name, def);
    }

    public int getInteger(String category, String propertyName) {
        Property prop = getProperty(category, propertyName);
        return prop.getInt();
    }

    /**
     * Boolean
     */
    public Property createProperty(String category, String name, boolean def) {
        return config.get(category, name, def);
    }

    public boolean getBool(String category, String propertyName) {
        Property prop = getProperty(category, propertyName);
        return prop.getBoolean();
    }

    /**
     * Double
     */
    public Property createProperty(String category, String name, double def) {
        return config.get(category, name, def);
    }

    public double getDouble(String category, String propertyName) {
        Property prop = getProperty(category, propertyName);
        return prop.getDouble();
    }

    /**
     * String
     */
    public Property createProperty(String category, String name, String def) {
        return config.get(category, name, def);
    }

    public String getString(String category, String propertyName) {
        Property prop = getProperty(category, propertyName);
        return prop.getString();
    }

    public void setComment(String category, String property, String comment) {
        Property prop = getProperty(category, property);
        prop.comment = comment;
    }


}

@@ -1259,35 +1259,25 @@
     
-Property prop = getProperty
+return config.get
 (cat
@@ -1295,38 +1295,20 @@
 ertyName
-);%0A        return prop
+, 0)
 .getInt(
@@ -1562,35 +1562,25 @@
     
-Property prop = getProperty
+return config.get
 (cat
@@ -1598,38 +1598,24 @@
 ertyName
-);%0A        return prop
+, false)
 .getBool
@@ -1872,35 +1872,25 @@
     
-Property prop = getProperty
+return config.get
 (cat
@@ -1908,38 +1908,24 @@
 ertyName
-);%0A        return prop
+, false)
 .getDoub
@@ -2181,35 +2181,25 @@
     
-Property prop = getProperty
+return config.get
 (cat
@@ -2221,30 +2221,16 @@
 Name
-);%0A        return prop
+, false)
 .get

Change how SourceConfig returns the values, avoids some NPEs.