mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-09-17 17:31:02 +02:00
7f8af7b5b3
- Permissions 2/3 are no longer supported - Changed ChestShop.shop.create permission to consist of 2 different permissions: ChestShop.shop.create.buy and ChestShop.shop.create.sell - (Experimental) Ability to add max item prices to the config - (Experimental) Added a custom "chestshop" WorldGuard flag using reflection - Switched to new Config system - Updated Metrics - Removed chest masking option
52 lines
1.6 KiB
Java
52 lines
1.6 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);
|
|
return !uSign.isSign(blockUp) || hasPermission(player, ((Sign) blockUp.getState()).getLines());
|
|
|
|
}
|
|
|
|
public static boolean canDestroy(Player p, Sign sign){
|
|
Sign shopSign = getAssociatedSign(sign);
|
|
return uSign.canAccess(p, shopSign);
|
|
}
|
|
|
|
public static Sign getAssociatedSign(Sign restricted){
|
|
Block down = restricted.getBlock().getRelative(BlockFace.DOWN);
|
|
return uSign.isSign(down) ? (Sign) down.getState() : null;
|
|
}
|
|
|
|
public static boolean hasPermission(Player p, String[] lines){
|
|
if (Permission.has(p, Permission.ADMIN)) return true;
|
|
|
|
for (int i = 1; i <= 3; i++) {
|
|
if (p.hasPermission(Permission.GROUP.toString() + lines[i])) return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|