From bd2a8daad3d5bd11113d4b95b12ade98c36ed999 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 31 Aug 2014 18:21:11 -0700 Subject: [PATCH] Fix sapling + bonemeal considered as usage rather than building. Fixes WORLDGUARD-3169. --- .../bukkit/listener/RegionProtectionListener.java | 7 ++++++- .../com/sk89q/worldguard/bukkit/util/Materials.java | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java b/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java index 4da1afd1..5d9afcce 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/listener/RegionProtectionListener.java @@ -246,8 +246,13 @@ public boolean apply(Location target) { boolean canUse; String what; + /* Saplings, etc. */ + if (Materials.isConsideredBuildingIfUsed(type)) { + canUse = query.testBuild(target, associable); + what = "use that"; + /* Inventory */ - if (Materials.isInventoryBlock(type)) { + } else if (Materials.isInventoryBlock(type)) { canUse = query.testBuild(target, associable, DefaultFlag.USE, DefaultFlag.CHEST_ACCESS); what = "open that"; diff --git a/src/main/java/com/sk89q/worldguard/bukkit/util/Materials.java b/src/main/java/com/sk89q/worldguard/bukkit/util/Materials.java index 3d0f88c4..baf82292 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/util/Materials.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/util/Materials.java @@ -616,4 +616,15 @@ public static boolean isItemAppliedToBlock(Material item, Material block) { return flags == null || (flags & MODIFIES_BLOCKS) == MODIFIES_BLOCKS; } + /** + * Test whether the given material should be tested as "building" when + * it is used. + * + * @param type the type + * @return true to be considered as used + */ + public static boolean isConsideredBuildingIfUsed(Material type) { + return type == Material.SAPLING; + } + }