MineLittlePony/src/main/java/com/brohoof/minelittlepony/PonyConfig.java

70 lines
2.4 KiB
Java
Raw Normal View History

2015-11-17 06:09:04 +01:00
package com.brohoof.minelittlepony;
2015-08-02 00:36:33 +02:00
import com.minelittlepony.minelp.util.MineLPLogger;
import com.voxelmodpack.common.properties.ModConfig;
public class PonyConfig extends ModConfig {
@Override
protected void setDefaults() {
this.defaults.setProperty("ponylevel", "2");
this.defaults.setProperty("sizes", "1");
this.defaults.setProperty("ponyarmor", "1");
this.defaults.setProperty("snuzzles", "1");
this.defaults.setProperty("hd", "1");
this.defaults.setProperty("showscale", "1");
this.defaults.setProperty("eqg", "0");
this.defaults.setProperty("villagers", "1");
this.defaults.setProperty("zombies", "1");
this.defaults.setProperty("pigzombies", "1");
this.defaults.setProperty("skeletons", "1");
this.defaults.setProperty("oldSkinUploaded", "0");
}
public PonyConfig() {
super("Mine Little Pony", "minelittlepony.properties");
}
@Override
public String getOptionDisplayString(String binding) {
return "";
}
public int getIntPropertySafe(String key) {
return this.getIntPropertySafe(key, Integer.MIN_VALUE, Integer.MAX_VALUE);
}
public int getIntPropertySafe(String key, int minValue, int maxValue) {
int value;
try {
value = this.getIntProperty(key);
} catch (Exception var9) {
try {
boolean e2 = this.getBoolProperty(key);
if (e2) {
value = 1;
} else {
value = 0;
}
} catch (Exception var8) {
int defaultValue1 = this.getDefaultIntProperty(key);
this.setProperty(key, defaultValue1);
2015-09-02 04:18:45 +02:00
MineLPLogger.error("Invalid value for config key \"%s\", using default value %d", key, defaultValue1);
2015-08-02 00:36:33 +02:00
return defaultValue1;
}
}
if (value >= minValue && value <= maxValue) {
return value;
}
2015-09-02 04:18:45 +02:00
int defaultValue = value = this.getDefaultIntProperty(key);
this.setProperty(key, defaultValue);
MineLPLogger.error("Invalid value for config key \"%s\", using default value %d. Found %d, expected value between %d and %d.",
key, defaultValue, value, minValue, maxValue);
return defaultValue;
2015-08-02 00:36:33 +02:00
}
public boolean isSet(String key) {
return this.config.containsKey(key);
}
}