mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-11-03 01:19:42 +01:00
Abstracted chest protection.
This commit is contained in:
parent
c75d612541
commit
474562455d
@ -24,6 +24,8 @@
|
|||||||
import com.sk89q.worldguard.blacklist.loggers.ConsoleLoggerHandler;
|
import com.sk89q.worldguard.blacklist.loggers.ConsoleLoggerHandler;
|
||||||
import com.sk89q.worldguard.blacklist.loggers.DatabaseLoggerHandler;
|
import com.sk89q.worldguard.blacklist.loggers.DatabaseLoggerHandler;
|
||||||
import com.sk89q.worldguard.blacklist.loggers.FileLoggerHandler;
|
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.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -54,7 +56,7 @@ public class WorldStateManager {
|
|||||||
private File blacklistFile;
|
private File blacklistFile;
|
||||||
|
|
||||||
private Blacklist blacklist;
|
private Blacklist blacklist;
|
||||||
private SignChestProtection chestProtection = new SignChestProtection();
|
private ChestProtection chestProtection = new SignChestProtection();
|
||||||
|
|
||||||
/* Configuration data start */
|
/* Configuration data start */
|
||||||
public boolean opPermissions;
|
public boolean opPermissions;
|
||||||
@ -367,7 +369,7 @@ public boolean isAdjacentChestProtected(Block block, Player player) {
|
|||||||
return chestProtection.isAdjacentChestProtected(block, player);
|
return chestProtection.isAdjacentChestProtected(block, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SignChestProtection getChestProtection() {
|
public ChestProtection getChestProtection() {
|
||||||
return chestProtection;
|
return chestProtection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
// $Id$
|
||||||
|
/*
|
||||||
|
* WorldGuard
|
||||||
|
* Copyright (C) 2010 sk89q <http://www.sk89q.com>
|
||||||
|
*
|
||||||
|
* 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 <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
@ -17,7 +17,7 @@
|
|||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package com.sk89q.worldguard.bukkit;
|
package com.sk89q.worldguard.chest;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
@ -26,11 +26,11 @@
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class for sign chest protection.
|
* Sign-based chest protection.
|
||||||
*
|
*
|
||||||
* @author sk89q
|
* @author sk89q
|
||||||
*/
|
*/
|
||||||
public class SignChestProtection {
|
public class SignChestProtection implements ChestProtection {
|
||||||
|
|
||||||
public boolean isProtected(Block block, Player player) {
|
public boolean isProtected(Block block, Player player) {
|
||||||
if (isChest(block.getType())) {
|
if (isChest(block.getType())) {
|
||||||
@ -120,13 +120,6 @@ private boolean isProtectedSignAndChestBinary(Block block, Player player) {
|
|||||||
return true;
|
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) {
|
public boolean isAdjacentChestProtected(Block searchBlock, Player player) {
|
||||||
Block side;
|
Block side;
|
||||||
Boolean res;
|
Boolean res;
|
||||||
@ -153,4 +146,11 @@ public boolean isAdjacentChestProtected(Block searchBlock, Player player) {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isChest(Material material) {
|
||||||
|
return material == Material.CHEST
|
||||||
|
|| material == Material.DISPENSER
|
||||||
|
|| material == Material.FURNACE
|
||||||
|
|| material == Material.BURNING_FURNACE;
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user