2011-07-23 21:00:47 +02:00
|
|
|
package com.Acrobot.ChestShop.Signs;
|
2011-06-23 23:25:34 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
2011-07-23 21:00:47 +02:00
|
|
|
public class restrictedSign {
|
|
|
|
public static boolean isRestrictedShop(Sign sign) {
|
|
|
|
Block blockUp = sign.getBlock().getRelative(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-23 21:00:47 +02:00
|
|
|
public static boolean isRestricted(Sign sign) {
|
|
|
|
return sign.getLine(0).equalsIgnoreCase("[restricted]");
|
|
|
|
}
|
|
|
|
|
2011-07-02 20:34:14 +02:00
|
|
|
public static boolean canAccess(Sign sign, Player player) {
|
2011-07-23 21:00:47 +02:00
|
|
|
Block blockUp = sign.getBlock().getRelative(BlockFace.UP);
|
|
|
|
if (Permission.permissions == null || !uSign.isSign(blockUp) || Permission.has(player, Permission.ADMIN)) return true;
|
|
|
|
|
2011-06-23 23:25:34 +02:00
|
|
|
String world = blockUp.getWorld().getName();
|
|
|
|
String playerName = player.getName();
|
|
|
|
|
|
|
|
sign = (Sign) blockUp.getState();
|
|
|
|
|
2011-07-02 20:34:14 +02:00
|
|
|
for (int i = 1; i <= 3; i++) {
|
2011-07-23 21:00:47 +02:00
|
|
|
if(Permission.permissions.inGroup(world, playerName, sign.getLine(i))) return true;
|
2011-06-23 23:25:34 +02:00
|
|
|
}
|
2011-07-23 21:00:47 +02:00
|
|
|
return false;
|
2011-06-23 23:25:34 +02:00
|
|
|
}
|
|
|
|
}
|