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;
|
|
|
|
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-05 19:08:55 +02:00
|
|
|
if ((uSign.isSign(block) && uSign.isValid((Sign) block.getState())) || uBlock.findSign(block) != null) {
|
2011-06-23 23:25:34 +02:00
|
|
|
return true;
|
|
|
|
} else {
|
2011-07-02 20:34:14 +02:00
|
|
|
if (!(block.getState() instanceof Chest)) {
|
2011-06-23 23:25:34 +02:00
|
|
|
return false;
|
|
|
|
}
|
2011-07-05 19:08:55 +02:00
|
|
|
if (uBlock.findSign(block) != null) {
|
2011-06-23 23:25:34 +02:00
|
|
|
return true;
|
|
|
|
}
|
2011-07-05 19:08:55 +02:00
|
|
|
Chest neighbor = uBlock.findNeighbor(block);
|
|
|
|
if (neighbor != null && uBlock.findSign(neighbor.getBlock()) != null) {
|
2011-06-23 23:25:34 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
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);
|
|
|
|
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())))
|
2011-06-23 23:25:34 +02:00
|
|
|
|| (nSign != null && nSign.getLine(0).equals(player.getName()));
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean protect(String name, Block block) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|