diff --git a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java index 4f334795..c72df15e 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/MVWorld.java @@ -109,7 +109,7 @@ public class MVWorld implements MultiverseWorld { this.propertyList.put("spawn", fac.getNewProperty("spawn", this.world.getSpawnLocation(), "There is no help available for this variable. Go bug Rigby90 about it.")); this.propertyList.put("autoload", fac.getNewProperty("autoload", true, "Set this to false ONLY if you don't want this world to load itself on server restart.")); this.propertyList.put("bedrespawn", fac.getNewProperty("bedrespawn", true, "If a player dies in this world, shoudld they go to their bed?")); - ((LocationConfigProperty) this.getKnownProperty("spawn")).setValue(this.readSpawnFromConfig(this.getCBWorld())); + this.getKnownProperty("spawn", Location.class).setValue(this.readSpawnFromConfig(this.getCBWorld())); // Set aliases @@ -144,28 +144,28 @@ public class MVWorld implements MultiverseWorld { public void changeActiveEffects() { // Disable any current weather - if (!(Boolean) this.getKnownProperty("weather").getValue()) { + if (!this.getKnownProperty("weather", Boolean.class).getValue()) { this.getCBWorld().setStorm(false); this.getCBWorld().setThundering(false); } // Set the spawn location - Location spawnLocation = ((LocationConfigProperty) this.getKnownProperty("spawn")).getValue(); + Location spawnLocation = this.getKnownProperty("spawn", Location.class).getValue(); this.getCBWorld().setSpawnLocation(spawnLocation.getBlockX(), spawnLocation.getBlockY(), spawnLocation.getBlockZ()); // Syncronize all Mob settings this.syncMobs(); // Ensure the memory setting is correct - this.world.setKeepSpawnInMemory(((BooleanConfigProperty) this.getKnownProperty("memory")).getValue()); + this.world.setKeepSpawnInMemory(this.getKnownProperty("memory", Boolean.class).getValue()); // Set the PVP mode - this.world.setPVP(((BooleanConfigProperty) this.getKnownProperty("pvp")).getValue()); + this.world.setPVP(this.getKnownProperty("pvp", Boolean.class).getValue()); // Ensure the scale is above 0 - if (((DoubleConfigProperty) this.getKnownProperty("scale")).getValue() <= 0) { + if (this.getKnownProperty("scale", Double.class).getValue() <= 0) { // Disallow negative or 0 scalings. - ((DoubleConfigProperty) this.getKnownProperty("scale")).setValue(1.0); + this.getKnownProperty("scale", Double.class).setValue(1.0); this.plugin.log(Level.WARNING, "Someone tried to set a scale <= 0, defaulting to 1."); } @@ -173,13 +173,13 @@ public class MVWorld implements MultiverseWorld { // TODO: Move this to a per world gamemode if (MultiverseCore.EnforceGameModes) { for (Player p : this.plugin.getServer().getWorld(this.getName()).getPlayers()) { - this.plugin.log(Level.FINER, "Setting " + p.getName() + "'s GameMode to " + this.getKnownProperty("mode").getValue().toString()); + this.plugin.log(Level.FINER, "Setting " + p.getName() + "'s GameMode to " + this.getKnownProperty("mode", GameMode.class).getValue().toString()); this.plugin.getPlayerListener().handleGameMode(p, this); } } // Set the difficulty - this.getCBWorld().setDifficulty(((DifficultyConfigProperty) this.getKnownProperty("diff")).getValue()); + this.getCBWorld().setDifficulty(this.getKnownProperty("diff", Difficulty.class).getValue()); } private double getDefaultScale(Environment environment) { @@ -216,8 +216,8 @@ public class MVWorld implements MultiverseWorld { } public String getColoredWorldString() { - EnglishChatColor worldColor = ((ColorConfigProperty) this.getKnownProperty("color")).getValue(); - String alias = ((StringConfigProperty) this.getKnownProperty("alias")).getValue(); + EnglishChatColor worldColor = this.getKnownProperty("color", EnglishChatColor.class).getValue(); + String alias = this.getKnownProperty("alias", String.class).getValue(); if (worldColor == null) { this.setKnownProperty("color", "WHITE", null); return alias + ChatColor.WHITE; @@ -310,12 +310,12 @@ public class MVWorld implements MultiverseWorld { private void syncMobs() { if (this.getAnimalList().isEmpty()) { - this.world.setSpawnFlags(this.world.getAllowMonsters(), ((BooleanConfigProperty) this.getKnownProperty("animals")).getValue()); + this.world.setSpawnFlags(this.world.getAllowMonsters(), this.getKnownProperty("animals", Boolean.class).getValue()); } else { this.world.setSpawnFlags(this.world.getAllowMonsters(), true); } if (this.getMonsterList().isEmpty()) { - this.world.setSpawnFlags(((BooleanConfigProperty) this.getKnownProperty("monsters")).getValue(), this.world.getAllowAnimals()); + this.world.setSpawnFlags(this.getKnownProperty("monsters", Boolean.class).getValue(), this.world.getAllowAnimals()); } else { this.world.setSpawnFlags(true, this.world.getAllowAnimals()); } @@ -324,7 +324,7 @@ public class MVWorld implements MultiverseWorld { @Override public void setKeepSpawnInMemory(boolean value) { - ((BooleanConfigProperty) this.getKnownProperty("memory")).setValue(value); + this.getKnownProperty("memory", Boolean.class).setValue(value); saveConfig(); } @@ -345,14 +345,20 @@ public class MVWorld implements MultiverseWorld { @Override public String getPropertyValue(String name) throws PropertyDoesNotExistException { if (this.propertyList.containsKey(name)) { - return this.getKnownProperty(name).toString(); + return this.getKnownProperty(name, Object.class).toString(); } throw new PropertyDoesNotExistException(name); } @Override - public MVConfigProperty getProperty(String name) throws PropertyDoesNotExistException { - MVConfigProperty p = this.getKnownProperty(name); + @Deprecated + public MVConfigProperty getProperty(String property) throws PropertyDoesNotExistException { + return getProperty(property, Object.class); + } + + @Override + public MVConfigProperty getProperty(String name, Class expected) throws PropertyDoesNotExistException { + MVConfigProperty p = this.getKnownProperty(name, expected); if (p == null) { throw new PropertyDoesNotExistException(name); } @@ -363,14 +369,19 @@ public class MVWorld implements MultiverseWorld { * This method should only be used from inside this class when it is KNOWN that the property exists. * * @param name The known name of a property + * @param expected The Type of the expected value * @return The property object. */ - private MVConfigProperty getKnownProperty(String name) { - if (this.propertyList.containsKey(name)) { - return this.propertyList.get(name); - } else if (this.propertyAliases.containsKey(name)) { - // If the property was defined in the alias table, make sure to grab the actual name - return this.propertyList.get(this.propertyAliases.get(name)); + @SuppressWarnings("unchecked") + private MVConfigProperty getKnownProperty(String name, Class expected) { + try { + if (this.propertyList.containsKey(name)) { + return (MVConfigProperty) this.propertyList.get(name); + } else if (this.propertyAliases.containsKey(name)) { + // If the property was defined in the alias table, make sure to grab the actual name + return (MVConfigProperty) this.propertyList.get(this.propertyAliases.get(name)); + } + } catch (ClassCastException e) { } return null; } @@ -386,7 +397,7 @@ public class MVWorld implements MultiverseWorld { private boolean setKnownProperty(String name, String value, CommandSender sender) { MVConfigProperty property; if (this.propertyList.containsKey(name)) { - property = this.getKnownProperty(name); + property = this.getKnownProperty(name, Object.class); } else if (this.propertyAliases.containsKey(name)) { return this.setKnownProperty(this.propertyAliases.get(name), value, sender); } else { @@ -441,7 +452,7 @@ public class MVWorld implements MultiverseWorld { @Override public String getAlias() { - String alias = ((StringConfigProperty) this.getKnownProperty("alias")).getValue(); + String alias = this.getKnownProperty("alias", String.class).getValue(); if (alias == null || alias.length() == 0) { return this.name; } @@ -456,7 +467,7 @@ public class MVWorld implements MultiverseWorld { @Override public boolean canAnimalsSpawn() { - return ((BooleanConfigProperty) this.getKnownProperty("animals")).getValue(); + return this.getKnownProperty("animals", Boolean.class).getValue(); } @Override @@ -471,7 +482,7 @@ public class MVWorld implements MultiverseWorld { @Override public boolean canMonstersSpawn() { - return ((BooleanConfigProperty) this.getKnownProperty("monsters")).getValue(); + return this.getKnownProperty("monsters", Boolean.class).getValue(); } @Override @@ -486,7 +497,7 @@ public class MVWorld implements MultiverseWorld { @Override public boolean isPVPEnabled() { - return ((BooleanConfigProperty) this.getKnownProperty("pvp")).getValue(); + return this.getKnownProperty("pvp", Boolean.class).getValue(); } @Override @@ -496,7 +507,7 @@ public class MVWorld implements MultiverseWorld { @Override public boolean isHidden() { - return ((BooleanConfigProperty) this.getKnownProperty("hidden")).getValue(); + return this.getKnownProperty("hidden", Boolean.class).getValue(); } @Override @@ -510,7 +521,7 @@ public class MVWorld implements MultiverseWorld { @Override public double getScaling() { - return ((DoubleConfigProperty) this.getKnownProperty("scale")).getValue(); + return this.getKnownProperty("scale", Double.class).getValue(); } @Override @@ -529,7 +540,7 @@ public class MVWorld implements MultiverseWorld { @Override public ChatColor getColor() { - return ((ColorConfigProperty) this.getKnownProperty("color")).getValue().getColor(); + return this.getKnownProperty("color", EnglishChatColor.class).getValue().getColor(); } public boolean clearList(String property) { @@ -550,7 +561,7 @@ public class MVWorld implements MultiverseWorld { @Override public World getRespawnToWorld() { - return (this.plugin.getServer().getWorld(((StringConfigProperty) this.getKnownProperty("respawn")).getValue())); + return (this.plugin.getServer().getWorld(this.getKnownProperty("respawn", String.class).getValue())); } @Override @@ -565,7 +576,7 @@ public class MVWorld implements MultiverseWorld { @Override public int getCurrency() { - return ((IntegerConfigProperty) this.getKnownProperty("curr")).getValue(); + return this.getKnownProperty("curr", Integer.class).getValue(); } @Override @@ -575,7 +586,7 @@ public class MVWorld implements MultiverseWorld { @Override public double getPrice() { - return ((DoubleConfigProperty) this.getKnownProperty("price")).getValue(); + return this.getKnownProperty("price", Double.class).getValue(); } @Override @@ -606,7 +617,7 @@ public class MVWorld implements MultiverseWorld { @Override public GameMode getGameMode() { - return ((GameModeConfigProperty) this.getKnownProperty("mode")).getValue(); + return this.getKnownProperty("mode", GameMode.class).getValue(); } @Override @@ -616,12 +627,12 @@ public class MVWorld implements MultiverseWorld { @Override public boolean isWeatherEnabled() { - return ((BooleanConfigProperty) this.getKnownProperty("weather")).getValue(); + return this.getKnownProperty("weather", Boolean.class).getValue(); } @Override public boolean isKeepingSpawnInMemory() { - return ((BooleanConfigProperty) this.getKnownProperty("memory")).getValue(); + return this.getKnownProperty("memory", Boolean.class).getValue(); } @Override @@ -631,13 +642,13 @@ public class MVWorld implements MultiverseWorld { @Override public boolean getHunger() { - return ((BooleanConfigProperty) this.getKnownProperty("hunger")).getValue(); + return this.getKnownProperty("hunger", Boolean.class).getValue(); } @Override public void setSpawnLocation(Location l) { this.getCBWorld().setSpawnLocation(l.getBlockX(), l.getBlockY(), l.getBlockZ()); - ((LocationConfigProperty) this.getKnownProperty("spawn")).setValue(l); + this.getKnownProperty("spawn", Location.class).setValue(l); this.saveConfig(); } @@ -690,7 +701,7 @@ public class MVWorld implements MultiverseWorld { @Override public Location getSpawnLocation() { - return ((LocationConfigProperty) this.getKnownProperty("spawn")).getValue(); + return this.getKnownProperty("spawn", Location.class).getValue(); } @Override @@ -705,7 +716,7 @@ public class MVWorld implements MultiverseWorld { @Override public boolean getAutoHeal() { - return ((BooleanConfigProperty) this.getKnownProperty("autoheal")).getValue(); + return this.getKnownProperty("autoheal", Boolean.class).getValue(); } @Override @@ -720,7 +731,7 @@ public class MVWorld implements MultiverseWorld { @Override public boolean getAdjustSpawn() { - return ((BooleanConfigProperty) this.getKnownProperty("adjustspawn")).getValue(); + return this.getKnownProperty("adjustspawn", Boolean.class).getValue(); } @Override @@ -730,7 +741,7 @@ public class MVWorld implements MultiverseWorld { @Override public boolean getAutoLoad() { - return ((BooleanConfigProperty) this.getKnownProperty("autoload")).getValue(); + return this.getKnownProperty("autoload", Boolean.class).getValue(); } @Override @@ -740,7 +751,7 @@ public class MVWorld implements MultiverseWorld { @Override public boolean getBedRespawn() { - return ((BooleanConfigProperty) this.getKnownProperty("bedrespawn")).getValue(); + return this.getKnownProperty("bedrespawn", Boolean.class).getValue(); } @Override diff --git a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java index 89c54b51..fb7d1a7c 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java +++ b/src/main/java/com/onarandombox/MultiverseCore/api/MultiverseWorld.java @@ -48,7 +48,9 @@ public interface MultiverseWorld { * @param property The name of a world property to get. * @return A valid MVWorldProperty. * @throws PropertyDoesNotExistException Thrown if the property was not found in the world. + * @deprecated Use {@link #getProperty(String, Class)} instead */ + @Deprecated public MVConfigProperty getProperty(String property) throws PropertyDoesNotExistException; /** @@ -61,6 +63,17 @@ public interface MultiverseWorld { */ public String getPropertyValue(String property) throws PropertyDoesNotExistException; + /** + * Gets the actual MVConfigProperty from this world. + * It will throw a PropertyDoesNotExistException if the property is not found. + * + * @param property The name of a world property to get. + * @param expected The type of the expected property. Use Object.class if this doesn't matter for you. + * @return A valid MVWorldProperty. + * @throws PropertyDoesNotExistException Thrown if the property was not found in the world. + */ + public MVConfigProperty getProperty(String property, Class expected) throws PropertyDoesNotExistException; + /** * Removes all values from the given property. The property must be a {@link com.onarandombox.MultiverseCore.enums.AddProperties}. * diff --git a/src/main/java/com/onarandombox/MultiverseCore/commands/ModifySetCommand.java b/src/main/java/com/onarandombox/MultiverseCore/commands/ModifySetCommand.java index 45203998..7ffc5cc0 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/commands/ModifySetCommand.java +++ b/src/main/java/com/onarandombox/MultiverseCore/commands/ModifySetCommand.java @@ -107,7 +107,7 @@ public class ModifySetCommand extends MultiverseCommand { if (world.setProperty(property, value, sender)) { sender.sendMessage(ChatColor.GREEN + "Success!" + ChatColor.WHITE + " Property " + ChatColor.AQUA + property + ChatColor.WHITE + " was set to " + ChatColor.GREEN + value); } else { - sender.sendMessage(world.getProperty(property).getHelp()); + sender.sendMessage(world.getProperty(property, Object.class).getHelp()); } } catch (PropertyDoesNotExistException e) { sender.sendMessage(ChatColor.RED + "Sorry, You can't set: '" + ChatColor.GRAY + property + ChatColor.RED + "'"); diff --git a/src/main/java/com/onarandombox/MultiverseCore/configuration/BooleanConfigProperty.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/BooleanConfigProperty.java index f94e9d9e..498faea2 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/configuration/BooleanConfigProperty.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/BooleanConfigProperty.java @@ -17,11 +17,7 @@ public class BooleanConfigProperty implements MVConfigProperty { 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 { this.configNode = configNode; this.section = section; this.help = help; + this.value = defaultValue; this.setValue(this.section.getBoolean(this.configNode, defaultValue)); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/configuration/ColorConfigProperty.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/ColorConfigProperty.java index d9b9d5fb..7ba3c551 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/configuration/ColorConfigProperty.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/ColorConfigProperty.java @@ -18,11 +18,7 @@ public class ColorConfigProperty implements MVConfigProperty { 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 { this.configNode = configNode; this.section = section; this.help = help; + this.value = defaultValue; this.parseValue(this.section.getString(this.configNode, defaultValue.toString())); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/configuration/DifficultyConfigProperty.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/DifficultyConfigProperty.java index 88d9c3fc..8b0097c7 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/configuration/DifficultyConfigProperty.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/DifficultyConfigProperty.java @@ -18,11 +18,7 @@ public class DifficultyConfigProperty implements MVConfigProperty { 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 { this.configNode = configNode; this.section = section; this.help = help; + this.value = defaultValue; this.parseValue(this.section.getString(this.configNode, defaultValue.toString())); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/configuration/DoubleConfigProperty.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/DoubleConfigProperty.java index 197a6f2f..0cfb0122 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/configuration/DoubleConfigProperty.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/DoubleConfigProperty.java @@ -17,11 +17,7 @@ public class DoubleConfigProperty implements MVConfigProperty { 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 { this.configNode = configNode; this.section = section; this.help = help; + this.value = defaultValue; this.setValue(this.section.getDouble(this.configNode, defaultValue)); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/configuration/GameModeConfigProperty.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/GameModeConfigProperty.java index 3603427b..976c1a88 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/configuration/GameModeConfigProperty.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/GameModeConfigProperty.java @@ -18,11 +18,7 @@ public class GameModeConfigProperty implements MVConfigProperty { 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 { this.configNode = configNode; this.section = section; this.help = help; + this.value = defaultValue; this.parseValue(this.section.getString(this.configNode, defaultValue.toString())); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/configuration/IntegerConfigProperty.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/IntegerConfigProperty.java index 958c4312..af5b3b0a 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/configuration/IntegerConfigProperty.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/IntegerConfigProperty.java @@ -17,11 +17,7 @@ public class IntegerConfigProperty implements MVConfigProperty { 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 { this.configNode = configNode; this.section = section; this.help = help; + this.value = defaultValue; this.setValue(this.section.getInt(this.configNode, defaultValue)); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/configuration/LocationConfigProperty.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/LocationConfigProperty.java index df6bc64c..ef886e64 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/configuration/LocationConfigProperty.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/LocationConfigProperty.java @@ -19,11 +19,7 @@ public class LocationConfigProperty implements MVConfigProperty { 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 { this.configNode = configNode; this.section = section; this.help = help; + this.value = defaultValue; this.setValue(this.getLocationFromConfig(defaultValue)); } diff --git a/src/main/java/com/onarandombox/MultiverseCore/configuration/StringConfigProperty.java b/src/main/java/com/onarandombox/MultiverseCore/configuration/StringConfigProperty.java index bbfddc4d..69e2afde 100644 --- a/src/main/java/com/onarandombox/MultiverseCore/configuration/StringConfigProperty.java +++ b/src/main/java/com/onarandombox/MultiverseCore/configuration/StringConfigProperty.java @@ -17,11 +17,7 @@ public class StringConfigProperty implements MVConfigProperty { 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 { this.configNode = configNode; this.section = section; this.help = help; + this.value = defaultValue; this.parseValue(this.section.getString(this.configNode, defaultValue)); } diff --git a/src/test/java/com/onarandombox/MultiverseCore/test/TestWorldStuff.java b/src/test/java/com/onarandombox/MultiverseCore/test/TestWorldStuff.java index 48419a24..5076d8f5 100644 --- a/src/test/java/com/onarandombox/MultiverseCore/test/TestWorldStuff.java +++ b/src/test/java/com/onarandombox/MultiverseCore/test/TestWorldStuff.java @@ -199,7 +199,7 @@ public class TestWorldStuff { // Now fail one. plugin.onCommand(mockCommandSender, mockCommand, "", new String[]{ "modify", "set", "mode", "fish", "world" }); try { - verify(mockCommandSender).sendMessage(mainWorld.getProperty("mode").getHelp()); + verify(mockCommandSender).sendMessage(mainWorld.getProperty("mode", Object.class).getHelp()); } catch (PropertyDoesNotExistException e) { fail("Mode property did not exist."); }