2011-09-01 18:59:15 +02:00
|
|
|
package com.Acrobot.ChestShop.Protection.Plugins;
|
2011-05-15 18:16:25 +02:00
|
|
|
|
2012-01-09 22:39:38 +01:00
|
|
|
import com.Acrobot.ChestShop.Permission;
|
2011-09-01 18:59:15 +02:00
|
|
|
import com.Acrobot.ChestShop.Protection.Protection;
|
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-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 (!(block.getState() instanceof Chest)) return false;
|
2011-10-11 13:15:53 +02:00
|
|
|
if (uBlock.findSign2(block) != null) return true;
|
2011-09-06 19:01:57 +02:00
|
|
|
|
2011-07-23 21:00:47 +02:00
|
|
|
Chest neighbor = uBlock.findNeighbor(block);
|
2011-10-11 13:15:53 +02:00
|
|
|
return neighbor != null && uBlock.findSign2(neighbor.getBlock()) != null;
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canAccess(Player player, Block block) {
|
2011-08-13 12:08:34 +02:00
|
|
|
String playerName = player.getName();
|
2011-09-06 19:01:57 +02:00
|
|
|
|
2011-10-11 13:15:53 +02:00
|
|
|
Sign sign = uBlock.findSign2(block);
|
2012-01-09 22:39:38 +01:00
|
|
|
|
|
|
|
if (sign != null) return uLongName.stripName(playerName).equals(sign.getLine(0))
|
|
|
|
|| Permission.otherName(player, sign.getLine(0));
|
2011-08-13 12:08:34 +02:00
|
|
|
|
2011-07-23 21:00:47 +02:00
|
|
|
Chest neighborChest = uBlock.findNeighbor(block);
|
2011-10-11 13:15:53 +02:00
|
|
|
Sign neighborSign = (neighborChest != null ? uBlock.findSign2(neighborChest.getBlock()) : null);
|
2011-09-06 19:01:57 +02:00
|
|
|
|
2012-01-09 22:39:38 +01:00
|
|
|
return neighborSign == null
|
|
|
|
|| uLongName.stripName(playerName).equals(neighborSign.getLine(0))
|
|
|
|
|| Permission.otherName(player, neighborSign.getLine(0));
|
2011-05-15 18:16:25 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public boolean protect(String name, Block block) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|