diff --git a/src/main/java/com/sk89q/worldguard/bukkit/WorldStateManager.java b/src/main/java/com/sk89q/worldguard/bukkit/WorldStateManager.java index 67911d6d..3ced6038 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/WorldStateManager.java +++ b/src/main/java/com/sk89q/worldguard/bukkit/WorldStateManager.java @@ -24,6 +24,8 @@ import com.sk89q.worldguard.blacklist.loggers.ConsoleLoggerHandler; import com.sk89q.worldguard.blacklist.loggers.DatabaseLoggerHandler; import com.sk89q.worldguard.blacklist.loggers.FileLoggerHandler; +import com.sk89q.worldguard.chest.ChestProtection; +import com.sk89q.worldguard.chest.SignChestProtection; import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; @@ -54,7 +56,7 @@ public class WorldStateManager { private File blacklistFile; private Blacklist blacklist; - private SignChestProtection chestProtection = new SignChestProtection(); + private ChestProtection chestProtection = new SignChestProtection(); /* Configuration data start */ public boolean opPermissions; @@ -367,7 +369,7 @@ public boolean isAdjacentChestProtected(Block block, Player player) { return chestProtection.isAdjacentChestProtected(block, player); } - public SignChestProtection getChestProtection() { + public ChestProtection getChestProtection() { return chestProtection; } diff --git a/src/main/java/com/sk89q/worldguard/chest/ChestProtection.java b/src/main/java/com/sk89q/worldguard/chest/ChestProtection.java new file mode 100644 index 00000000..98246f28 --- /dev/null +++ b/src/main/java/com/sk89q/worldguard/chest/ChestProtection.java @@ -0,0 +1,67 @@ +// $Id$ +/* + * WorldGuard + * Copyright (C) 2010 sk89q + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +package com.sk89q.worldguard.chest; + +import org.bukkit.Material; +import org.bukkit.block.Block; +import org.bukkit.entity.Player; + +/** + * Interface for chest protection. + */ +public interface ChestProtection { + + /** + * Returns whether a block is protected. + * + * @param block + * @param player + * @return + */ + public boolean isProtected(Block block, Player player); + + /** + * Returns whether a location where a chest block is trying to be created + * is protected. + * + * @param block + * @param player + * @return + */ + public boolean isProtectedPlacement(Block block, Player player); + + /** + * Returns whether an adjacent chest is protected. + * + * @param searchBlock + * @param player + * @return + */ + public boolean isAdjacentChestProtected(Block searchBlock, Player player); + + /** + * Returns whether a material is a chest. + * + * @param material + * @return + */ + public boolean isChest(Material material); + +} \ No newline at end of file diff --git a/src/main/java/com/sk89q/worldguard/bukkit/SignChestProtection.java b/src/main/java/com/sk89q/worldguard/chest/SignChestProtection.java similarity index 94% rename from src/main/java/com/sk89q/worldguard/bukkit/SignChestProtection.java rename to src/main/java/com/sk89q/worldguard/chest/SignChestProtection.java index c5e1c819..eebad59e 100644 --- a/src/main/java/com/sk89q/worldguard/bukkit/SignChestProtection.java +++ b/src/main/java/com/sk89q/worldguard/chest/SignChestProtection.java @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -package com.sk89q.worldguard.bukkit; +package com.sk89q.worldguard.chest; import org.bukkit.Material; import org.bukkit.block.Block; @@ -26,11 +26,11 @@ import org.bukkit.entity.Player; /** - * Utility class for sign chest protection. + * Sign-based chest protection. * * @author sk89q */ -public class SignChestProtection { +public class SignChestProtection implements ChestProtection { public boolean isProtected(Block block, Player player) { if (isChest(block.getType())) { @@ -119,13 +119,6 @@ private boolean isProtectedSignAndChestBinary(Block block, Player player) { } return true; } - - public boolean isChest(Material material) { - return material == Material.CHEST - || material == Material.DISPENSER - || material == Material.FURNACE - || material == Material.BURNING_FURNACE; - } public boolean isAdjacentChestProtected(Block searchBlock, Player player) { Block side; @@ -153,4 +146,11 @@ public boolean isAdjacentChestProtected(Block searchBlock, Player player) { return false; } + + public boolean isChest(Material material) { + return material == Material.CHEST + || material == Material.DISPENSER + || material == Material.FURNACE + || material == Material.BURNING_FURNACE; + } }