Merge remote-tracking branch 'origin/master'

This commit is contained in:
Sauilitired 2014-10-18 13:55:11 +02:00
commit dae0b00e35
4 changed files with 42 additions and 14 deletions

View File

@ -39,5 +39,14 @@ public class AbstractFlag {
public String toString() { public String toString() {
return this.key; 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));
}
} }

View File

@ -11,11 +11,17 @@ import java.util.List;
import static org.bukkit.Material.*; import static org.bukkit.Material.*;
/**
*
* @author Jesse Boyd
*
*/
public abstract class PlotWorld { public abstract class PlotWorld {
// TODO make this configurable // TODO make this configurable
// make non static and static_default_valu + add config option // make non static and static_default_valu + add config option
public static ArrayList<Material> BLOCKS = new ArrayList<Material>(Arrays.asList(new Material[] { ACACIA_STAIRS, @SuppressWarnings("deprecation")
public static ArrayList<Material> BLOCKS = new ArrayList<Material>(Arrays.asList(new Material[] { ACACIA_STAIRS,
BEACON, BEDROCK, BIRCH_WOOD_STAIRS, BOOKSHELF, BREWING_STAND, BRICK, BRICK_STAIRS, BURNING_FURNACE, 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, 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, COMMAND, DARK_OAK_STAIRS, DAYLIGHT_DETECTOR, DIAMOND_ORE, DIAMOND_BLOCK, DIRT, DISPENSER, DROPPER,
@ -91,7 +97,8 @@ public abstract class PlotWorld {
* *
@param config @param config
*/ */
public void loadDefaultConfiguration(ConfigurationSection config) { public void loadDefaultConfiguration(ConfigurationSection config)
{
this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning"); this.MOB_SPAWNING = config.getBoolean("natural_mob_spawning");
this.AUTO_MERGE = config.getBoolean("plot.auto_merge"); this.AUTO_MERGE = config.getBoolean("plot.auto_merge");
this.PLOT_BIOME = (Biome) Configuration.BIOME.parseString(config.getString("plot.biome")); 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 abstract void loadConfiguration(ConfigurationSection config);
public void saveConfiguration(ConfigurationSection config) { /**
* Saving core plotworld settings
/* * @param config
* Saving core plotworld settings */
*/ public void saveConfiguration(ConfigurationSection config)
{
HashMap<String, Object> options = new HashMap<String, Object>(); HashMap<String, Object> options = new HashMap<String, Object>();
options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT); options.put("natural_mob_spawning", PlotWorld.MOB_SPAWNING_DEFAULT);
@ -146,11 +153,13 @@ public abstract class PlotWorld {
/* /*
* Saving generator specific settings * Saving generator specific settings
*/ */
for (ConfigurationNode setting : settings) { for (ConfigurationNode setting : settings)
{
options.put(setting.getConstant(), setting.getType().parseObject(setting.getValue())); options.put(setting.getConstant(), setting.getType().parseObject(setting.getValue()));
} }
for (String option : options.keySet()) { for (String option : options.keySet())
{
if (!config.contains(option)) { if (!config.contains(option)) {
config.set(option, options.get(option)); config.set(option, options.get(option));
} }

View File

@ -20,6 +20,7 @@ import org.bukkit.WeatherType;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import com.intellectualcrafters.plot.AbstractFlag;
import com.intellectualcrafters.plot.C; import com.intellectualcrafters.plot.C;
import com.intellectualcrafters.plot.Flag; import com.intellectualcrafters.plot.Flag;
import com.intellectualcrafters.plot.FlagManager; import com.intellectualcrafters.plot.FlagManager;
@ -96,8 +97,17 @@ public class Set extends SubCommand {
PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message)); PlayerFunctions.sendMessage(plr, C.NEED_KEY.s().replaceAll("%values%", message));
return false; 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); PlayerFunctions.sendMessage(plr, C.NOT_VALID_FLAG);
return false; return false;
} }

View File

@ -125,7 +125,7 @@ public class DefaultPlotWorld extends PlotWorld {
super(worldname); super(worldname);
} }
/* /**
* CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED * CONFIG NODE | DEFAULT VALUE | DESCRIPTION | CONFIGURATION TYPE | REQUIRED
* FOR INITIAL SETUP * 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), }; 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 * 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 * constants here. You are provided with the configuration section for that
* specific world. * specific world.