From 8f09a19a06f95fb0263a38592bed44be8c740e06 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Tue, 14 Apr 2015 23:55:00 +1000 Subject: [PATCH] Should fix #267 --- .../com/intellectualcrafters/plot/commands/Set.java | 6 ++++++ .../intellectualcrafters/plot/util/BlockManager.java | 2 ++ .../plot/util/SchematicHandler.java | 11 +++++++++++ .../plot/util/bukkit/BukkitUtil.java | 11 +++++++++++ 4 files changed, 30 insertions(+) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java index b24829271..b90d2193f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -240,6 +240,12 @@ public class Set extends SubCommand { return true; } blocks = new PlotBlock[] { new PlotBlock((short) BlockManager.manager.getBlockIdFromString(args[1]), (byte) 0) }; + for (PlotBlock block : blocks) { + if (!BlockManager.manager.isBlockSolid(block)) { + MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK); + return false; + } + } } catch (final Exception e2) { MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK); return false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index 93c54dbc4..ebaea69c7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -6,6 +6,8 @@ import com.intellectualcrafters.plot.object.schematic.PlotItem; public abstract class BlockManager { public static BlockManager manager; + + public abstract boolean isBlockSolid(PlotBlock block); public abstract String[] getBiomeList(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index ce35aab44..9bc3b5c7f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -183,6 +183,17 @@ public abstract class SchematicHandler { } } final File file = new File(PlotSquared.IMP.getDirectory() + File.separator + "schematics" + File.separator + name + ".schematic"); + return getSchematic(file); + } + + /** + * Get a schematic + * + * @param name to check + * + * @return schematic if found, else null + */ + public Schematic getSchematic(File file) { if (!file.exists()) { PlotSquared.log(file.toString() + " doesn't exist"); return null; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index 04be68615..9312ebbee 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -293,4 +293,15 @@ public class BukkitUtil extends BlockManager { return false; } + + @Override + public boolean isBlockSolid(PlotBlock block) { + try { + Material material = Material.getMaterial(block.id); + return material.isBlock() && material.isSolid() && material.isOccluding() && !material.hasGravity(); + } + catch (Exception e) { + return false; + } + } }