2011-06-23 23:25:34 +02:00
|
|
|
package com.Acrobot.ChestShop.Restrictions;
|
|
|
|
|
|
|
|
import com.Acrobot.ChestShop.Permission;
|
2011-07-05 19:08:55 +02:00
|
|
|
import com.Acrobot.ChestShop.Utils.uSign;
|
2011-06-23 23:25:34 +02:00
|
|
|
import org.bukkit.block.Block;
|
|
|
|
import org.bukkit.block.BlockFace;
|
|
|
|
import org.bukkit.block.Sign;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @author Acrobot
|
|
|
|
*/
|
|
|
|
public class RestrictedSign {
|
2011-07-02 20:34:14 +02:00
|
|
|
public static boolean isRestricted(Sign sign) {
|
2011-06-23 23:25:34 +02:00
|
|
|
Block blockUp = sign.getBlock().getFace(BlockFace.UP);
|
2011-07-05 19:08:55 +02:00
|
|
|
return uSign.isSign(blockUp) && isRestricted(((Sign) blockUp.getState()).getLines());
|
2011-06-23 23:25:34 +02:00
|
|
|
}
|
|
|
|
|
2011-07-02 20:34:14 +02:00
|
|
|
public static boolean isRestricted(String[] lines) {
|
2011-06-23 23:25:34 +02:00
|
|
|
return lines[0].equalsIgnoreCase("[restricted]");
|
|
|
|
}
|
|
|
|
|
2011-07-02 20:34:14 +02:00
|
|
|
public static boolean canAccess(Sign sign, Player player) {
|
2011-06-23 23:25:34 +02:00
|
|
|
Block blockUp = sign.getBlock().getFace(BlockFace.UP);
|
2011-07-05 19:08:55 +02:00
|
|
|
if (Permission.permissions == null || !uSign.isSign(blockUp) || Permission.has(player, Permission.ADMIN)) {
|
2011-06-23 23:25:34 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
String world = blockUp.getWorld().getName();
|
|
|
|
String playerName = player.getName();
|
|
|
|
|
|
|
|
sign = (Sign) blockUp.getState();
|
|
|
|
|
|
|
|
boolean result = false;
|
2011-07-02 20:34:14 +02:00
|
|
|
for (int i = 1; i <= 3; i++) {
|
2011-06-23 23:25:34 +02:00
|
|
|
result = result || Permission.permissions.inGroup(world, playerName, sign.getLine(i));
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|