2011-05-15 19:33:03 +02:00
|
|
|
package com.Acrobot.ChestShop.Protection;
|
2011-05-15 18:16:25 +02:00
|
|
|
|
2011-07-05 19:08:55 +02:00
|
|
|
import com.Acrobot.ChestShop.Utils.uBlock;
|
2011-07-23 21:00:47 +02:00
|
|
|
import com.Acrobot.ChestShop.Utils.uLongName;
|
2011-07-05 19:08:55 +02:00
|
|
|
import com.Acrobot.ChestShop.Utils.uSign;
|
2011-05-15 18:16:25 +02:00
|
|
|
import org.bukkit.block.Block;
|
2011-06-19 23:52:36 +02:00
|
|
|
import org.bukkit.block.Chest;
|
2011-05-21 19:55:55 +02:00
|
|
|
import org.bukkit.block.Sign;
|
2011-05-15 18:16:25 +02:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Acrobot
|
|
|
|
*/
|
2011-05-29 13:25:25 +02:00
|
|
|
public class Default implements Protection {
|
2011-05-15 18:16:25 +02:00
|
|
|
public boolean isProtected(Block block) {
|
2011-07-23 21:00:47 +02:00
|
|
|
if ((uSign.isSign(block) && uSign.isValid((Sign) block.getState())) || uBlock.findSign(block) != null) return true;
|
|
|
|
if (!(block.getState() instanceof Chest)) return false;
|
2011-06-23 23:25:34 +02:00
|
|
|
|
2011-07-23 21:00:47 +02:00
|
|
|
Chest neighbor = uBlock.findNeighbor(block);
|
|
|
|
return neighbor != null && uBlock.findSign(neighbor.getBlock()) != null;
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canAccess(Player player, Block block) {
|
2011-07-05 19:08:55 +02:00
|
|
|
Sign sign = uBlock.findSign(block);
|
2011-07-23 21:00:47 +02:00
|
|
|
Chest neighborChest = uBlock.findNeighbor(block);
|
|
|
|
Sign neighborSign = (neighborChest != null ? uBlock.findSign(neighborChest.getBlock()) : null);
|
|
|
|
|
|
|
|
String playerName = player.getName();
|
|
|
|
String signLine = "";
|
|
|
|
if (uSign.isSign(block) && uSign.isValid((Sign) block.getState())) signLine = ((Sign) block.getState()).getLine(0);
|
|
|
|
if (sign != null) signLine = sign.getLine(0);
|
|
|
|
if (neighborSign != null) signLine = neighborSign.getLine(0);
|
|
|
|
|
2011-07-24 16:56:18 +02:00
|
|
|
return uLongName.stripName(playerName).equals(signLine);
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean protect(String name, Block block) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|