ChestShop-3/com/Acrobot/ChestShop/Restrictions/RestrictedSign.java

40 lines
1.3 KiB
Java
Raw Normal View History

package com.Acrobot.ChestShop.Restrictions;
import com.Acrobot.ChestShop.Permission;
import com.Acrobot.ChestShop.Utils.SignUtil;
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 {
public static boolean isRestricted(Sign sign){
Block blockUp = sign.getBlock().getFace(BlockFace.UP);
return SignUtil.isSign(blockUp) && isRestricted(((Sign) blockUp.getState()).getLines());
}
public static boolean isRestricted(String[] lines){
return lines[0].equalsIgnoreCase("[restricted]");
}
public static boolean canAccess(Sign sign, Player player){
Block blockUp = sign.getBlock().getFace(BlockFace.UP);
if(Permission.permissions == null || !SignUtil.isSign(blockUp) || Permission.has(player, Permission.ADMIN)){
return true;
}
String world = blockUp.getWorld().getName();
String playerName = player.getName();
sign = (Sign) blockUp.getState();
boolean result = false;
for(int i = 1; i <= 3; i++){
result = result || Permission.permissions.inGroup(world, playerName, sign.getLine(i));
}
return result;
}
}