From 2edec161a81212fa43ad5d56416a74211f1a0355 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 18 Oct 2014 21:28:15 +1100 Subject: [PATCH] my bad --- .../plot/AbstractFlag.java | 9 ++++++ .../intellectualcrafters/plot/PlotWorld.java | 29 ++++++++++++------- .../plot/commands/Set.java | 14 +++++++-- .../plot/generator/DefaultPlotWorld.java | 4 +-- 4 files changed, 42 insertions(+), 14 deletions(-) diff --git a/PlotSquared/src/com/intellectualcrafters/plot/AbstractFlag.java b/PlotSquared/src/com/intellectualcrafters/plot/AbstractFlag.java index 9632dd469..3c5755a46 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/AbstractFlag.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/AbstractFlag.java @@ -39,5 +39,14 @@ public class AbstractFlag { public String toString() { return this.key; } + + @Override + public boolean equals(Object other){ + if (other == null) return false; + if (other == this) return true; + if (!(other instanceof AbstractFlag)) return false; + AbstractFlag otherObj = (AbstractFlag)other; + return (otherObj.key.equals(this.key)); + } } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java index e3d3e7c80..76b196818 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java @@ -11,11 +11,17 @@ import java.util.List; import static org.bukkit.Material.*; +/** + * + * @author Jesse Boyd + * + */ public abstract class PlotWorld { // TODO make this configurable // make non static and static_default_valu + add config option - public static ArrayList BLOCKS = new ArrayList(Arrays.asList(new Material[] { ACACIA_STAIRS, + @SuppressWarnings("deprecation") + public static ArrayList BLOCKS = new ArrayList(Arrays.asList(new Material[] { ACACIA_STAIRS, BEACON, BEDROCK, BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, BRICK_STAIRS, BURNING_FURNACE, CAKE_BLOCK, CAULDRON, CLAY_BRICK, CLAY, COAL_BLOCK, COAL_ORE, COBBLE_WALL, COBBLESTONE, COBBLESTONE_STAIRS, COMMAND, DARK_OAK_STAIRS, DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, DISPENSER, DROPPER, @@ -91,7 +97,8 @@ public abstract class PlotWorld { * @param config */ - public void loadDefaultConfiguration(ConfigurationSection config) { + public void loadDefaultConfiguration(ConfigurationSection config) + { this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning"); this.AUTO_MERGE = config.getBoolean("plot.auto_merge"); this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config.getString("plot.biome")); @@ -115,12 +122,12 @@ public abstract class PlotWorld { public abstract void loadConfiguration(ConfigurationSection config); - public void saveConfiguration(ConfigurationSection config) { - - /* - * Saving core plotworld settings - */ - + /** + * Saving core plotworld settings + * @param config + */ + public void saveConfiguration(ConfigurationSection config) + { HashMap options = new HashMap(); options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT); @@ -146,11 +153,13 @@ public abstract class PlotWorld { /* * Saving generator specific settings */ - for (ConfigurationNode setting : settings) { + for (ConfigurationNode setting : settings) + { options.put(setting.getConstant(), setting.getType().parseObject(setting.getValue())); } - for (String option : options.keySet()) { + for (String option : options.keySet()) + { if (!config.contains(option)) { config.set(option, options.get(option)); } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java index 9500fb30f..1bc032a3a 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Set.java @@ -20,6 +20,7 @@ import org.bukkit.WeatherType; import org.bukkit.block.Biome; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.AbstractFlag; import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.Flag; import com.intellectualcrafters.plot.FlagManager; @@ -96,8 +97,17 @@ public class Set extends SubCommand { PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message)); return false; } - if (!FlagManager.getFlags().contains(args[1].toLowerCase()) && (PlotMain.worldGuardListener != null) - && !PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase())) { + + AbstractFlag af = new AbstractFlag(""); + + try { + af = new AbstractFlag(args[1].toLowerCase()); + } + catch (Exception e) { + + } + + if (!FlagManager.getFlags().contains(af) && ((PlotMain.worldGuardListener == null) || !PlotMain.worldGuardListener.str_flags.contains(args[1].toLowerCase()))) { PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG); return false; } diff --git a/PlotSquared/src/com/intellectualcrafters/plot/generator/DefaultPlotWorld.java b/PlotSquared/src/com/intellectualcrafters/plot/generator/DefaultPlotWorld.java index ab35f5c96..0a9804df4 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/generator/DefaultPlotWorld.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/generator/DefaultPlotWorld.java @@ -125,7 +125,7 @@ public class DefaultPlotWorld extends PlotWorld { super(worldname); } - /* + /** * CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED * FOR INITIAL SETUP * @@ -152,7 +152,7 @@ public class DefaultPlotWorld extends PlotWorld { new ConfigurationNode("wall.height", DefaultPlotWorld.WALL_HEIGHT_DEFAULT, "Wall height", Configuration.INTEGER, true), }; } - /* + /** * This method is called when a world loads. Make sure you set all your * constants here. You are provided with the configuration section for that * specific world.