From 2b0d73621a358d74e9edace746d891889a865547 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sat, 2 Oct 2010 16:28:02 -0700 Subject: [PATCH] Allowed blocks list can now be adjusted in worldedit.properties. --- src/WorldEdit.java | 43 +++++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/src/WorldEdit.java b/src/WorldEdit.java index 4c22d4fe3..89de13769 100644 --- a/src/WorldEdit.java +++ b/src/WorldEdit.java @@ -30,10 +30,21 @@ import com.sk89q.worldedit.*; * @author sk89q */ public class WorldEdit extends Plugin { + private final static String DEFAULT_ALLOWED_BLOCKS = + "0,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,35,41,42,43," + + "44,45,47,48,49,52,53,54,56,57,58,60,61,62,67,73,78,79,80,81,82,85"; + private static Logger logger = Logger.getLogger("Minecraft"); private HashMap sessions = new HashMap(); private HashMap commands = new HashMap(); + private PropertiesFile properties; + /** + * List of allowed blocks as a list of numbers as Strings. Not converted + * to a more usuable format. + */ + private String[] allowedBlocks; + public WorldEdit() { super(); @@ -58,6 +69,14 @@ public class WorldEdit extends Plugin { * Enables the plugin. */ public void enable() { + if (properties == null) { + properties = new PropertiesFile("worldedit.properties"); + } else { + properties.load(); + } + + allowedBlocks = properties.getString("allowed-blocks", DEFAULT_ALLOWED_BLOCKS).split(","); + etc controller = etc.getInstance(); for (Map.Entry entry : commands.entrySet()) { @@ -116,22 +135,18 @@ public class WorldEdit extends Plugin { } } - if ((foundID >= 0 && foundID <= 5) || - (foundID >= 7 && foundID <= 20) || - foundID == 35 || - (foundID >= 41 && foundID <= 45) || - (foundID >= 47 && foundID <= 49) || - (foundID >= 52 && foundID <= 54) || - (foundID >= 56 && foundID <= 58) || - (foundID >= 60 && foundID <= 62) || - foundID == 67 || - foundID == 73 || - (foundID >= 78 && foundID <= 82) || - foundID == 85) { + // All items allowed + if (allowedBlocks[0].equals("")) { return foundID; - } else { - throw new DisallowedItemException(); } + + for (String s : allowedBlocks) { + if (s.equals(String.valueOf(foundID))) { + return foundID; + } + } + + throw new DisallowedItemException(); } /**