Prevented properties from getting null if they were invalid in worlds.yml

This commit is contained in:
main() 2011-12-10 21:03:38 +01:00
parent c0ae0e3eea
commit c9cd2a0f5c
8 changed files with 16 additions and 40 deletions

View File

@ -17,11 +17,7 @@ public class BooleanConfigProperty implements MVConfigProperty<Boolean> {
private String help;
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue, String help) {
this.name = name;
this.configNode = name;
this.section = section;
this.help = help;
this.setValue(this.section.getBoolean(this.configNode, defaultValue));
this(section, name, defaultValue, name, help);
}
public BooleanConfigProperty(ConfigurationSection section, String name, Boolean defaultValue, String configNode, String help) {
@ -29,6 +25,7 @@ public class BooleanConfigProperty implements MVConfigProperty<Boolean> {
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.setValue(this.section.getBoolean(this.configNode, defaultValue));
}

View File

@ -18,11 +18,7 @@ public class ColorConfigProperty implements MVConfigProperty<EnglishChatColor> {
private String help;
public ColorConfigProperty(ConfigurationSection section, String name, EnglishChatColor defaultValue, String help) {
this.name = name;
this.configNode = name;
this.section = section;
this.help = help;
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
this(section, name, defaultValue, name, help);
}
public ColorConfigProperty(ConfigurationSection section, String name, EnglishChatColor defaultValue, String configNode, String help) {
@ -30,6 +26,7 @@ public class ColorConfigProperty implements MVConfigProperty<EnglishChatColor> {
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
}

View File

@ -18,11 +18,7 @@ public class DifficultyConfigProperty implements MVConfigProperty<Difficulty> {
private String help;
public DifficultyConfigProperty(ConfigurationSection section, String name, Difficulty defaultValue, String help) {
this.name = name;
this.configNode = name;
this.section = section;
this.help = help;
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
this(section, name, defaultValue, name, help);
}
public DifficultyConfigProperty(ConfigurationSection section, String name, Difficulty defaultValue, String configNode, String help) {
@ -30,6 +26,7 @@ public class DifficultyConfigProperty implements MVConfigProperty<Difficulty> {
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
}

View File

@ -17,11 +17,7 @@ public class DoubleConfigProperty implements MVConfigProperty<Double> {
private String help;
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue, String help) {
this.name = name;
this.configNode = name;
this.section = section;
this.help = help;
this.setValue(this.section.getDouble(this.configNode, defaultValue));
this(section, name, defaultValue, name, help);
}
public DoubleConfigProperty(ConfigurationSection section, String name, Double defaultValue, String configNode, String help) {
@ -29,6 +25,7 @@ public class DoubleConfigProperty implements MVConfigProperty<Double> {
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.setValue(this.section.getDouble(this.configNode, defaultValue));
}

View File

@ -18,11 +18,7 @@ public class GameModeConfigProperty implements MVConfigProperty<GameMode> {
private String help;
public GameModeConfigProperty(ConfigurationSection section, String name, GameMode defaultValue, String help) {
this.name = name;
this.configNode = name;
this.section = section;
this.help = help;
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
this(section, name, defaultValue, name, help);
}
public GameModeConfigProperty(ConfigurationSection section, String name, GameMode defaultValue, String configNode, String help) {
@ -30,6 +26,7 @@ public class GameModeConfigProperty implements MVConfigProperty<GameMode> {
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.parseValue(this.section.getString(this.configNode, defaultValue.toString()));
}

View File

@ -17,11 +17,7 @@ public class IntegerConfigProperty implements MVConfigProperty<Integer> {
private String help;
public IntegerConfigProperty(ConfigurationSection section, String name, Integer defaultValue, String help) {
this.name = name;
this.configNode = name;
this.section = section;
this.help = help;
this.setValue(this.section.getInt(this.configNode, defaultValue));
this(section, name, defaultValue, name, help);
}
public IntegerConfigProperty(ConfigurationSection section, String name, Integer defaultValue, String configNode, String help) {
@ -29,6 +25,7 @@ public class IntegerConfigProperty implements MVConfigProperty<Integer> {
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.setValue(this.section.getInt(this.configNode, defaultValue));
}

View File

@ -19,11 +19,7 @@ public class LocationConfigProperty implements MVConfigProperty<Location> {
private String help;
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue, String help) {
this.name = name;
this.configNode = name;
this.section = section;
this.help = help;
this.setValue(this.getLocationFromConfig(defaultValue));
this(section, name, defaultValue, name, help);
}
public LocationConfigProperty(ConfigurationSection section, String name, Location defaultValue, String configNode, String help) {
@ -31,6 +27,7 @@ public class LocationConfigProperty implements MVConfigProperty<Location> {
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.setValue(this.getLocationFromConfig(defaultValue));
}

View File

@ -17,11 +17,7 @@ public class StringConfigProperty implements MVConfigProperty<String> {
private String help;
public StringConfigProperty(ConfigurationSection section, String name, String defaultValue, String help) {
this.name = name;
this.configNode = name;
this.section = section;
this.help = help;
this.parseValue(this.section.getString(this.configNode, defaultValue));
this(section, name, defaultValue, defaultValue, help);
}
public StringConfigProperty(ConfigurationSection section, String name, String defaultValue, String configNode, String help) {
@ -29,6 +25,7 @@ public class StringConfigProperty implements MVConfigProperty<String> {
this.configNode = configNode;
this.section = section;
this.help = help;
this.value = defaultValue;
this.parseValue(this.section.getString(this.configNode, defaultValue));
}