ChestShop-3/com/Acrobot/ChestShop/Signs/restrictedSign.java
Acrobot 7b6d7d59bd - Long name (>15 chars) support
- Added Bukkit Persistence Reimplemented by LennardF1989
- Made the plugin faster
- Deleted unnecessary files (.jar size went down by 10 KB)
- Added final and private keywords
- Support for Bukkit's built-in permissions
- Updated to newest Bukkit's standard (getFace -> getRelative)
2011-07-23 21:00:47 +02:00

42 lines
1.3 KiB
Java

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