ChestShop-3/com/Acrobot/ChestShop/Protection/Default.java

45 lines
1.5 KiB
Java
Raw Normal View History

2011-05-15 19:33:03 +02:00
package com.Acrobot.ChestShop.Protection;
import com.Acrobot.ChestShop.Utils.uBlock;
import com.Acrobot.ChestShop.Utils.uSign;
import org.bukkit.block.Block;
import org.bukkit.block.Chest;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
/**
* @author Acrobot
*/
2011-05-29 13:25:25 +02:00
public class Default implements Protection {
public boolean isProtected(Block block) {
if ((uSign.isSign(block) && uSign.isValid((Sign) block.getState())) || uBlock.findSign(block) != null) {
return true;
} else {
2011-07-02 20:34:14 +02:00
if (!(block.getState() instanceof Chest)) {
return false;
}
if (uBlock.findSign(block) != null) {
return true;
}
Chest neighbor = uBlock.findNeighbor(block);
if (neighbor != null && uBlock.findSign(neighbor.getBlock()) != null) {
return true;
}
}
return false;
}
public boolean canAccess(Player player, Block block) {
Sign sign = uBlock.findSign(block);
Chest nChest = uBlock.findNeighbor(block);
Sign nSign = (nChest != null ? uBlock.findSign(nChest.getBlock()) : null);
return ((uSign.isSign(block) && uSign.isValid((Sign) block.getState()) && ((Sign) block.getState()).getLine(0).equals(player.getName())) || (sign != null && sign.getLine(0).equals(player.getName())))
|| (nSign != null && nSign.getLine(0).equals(player.getName()));
}
public boolean protect(String name, Block block) {
return false;
}
}