mirror of
https://github.com/ChestShop-authors/ChestShop-3.git
synced 2024-08-18 03:12:47 +02:00
- Formatting - Warning about old Bukkit version - Renamed "TOWNY_CANNOT_CREATE_SHOP_HERE" to "CANNOT_CREATE_SHOP_HERE" to avoid confusion - Renamed "NOT_ENOUGH_LWC_PROTECTIONS" to "NOT_ENOUGH_PROTECTIONS" and changed its message - Fixed armour enchantments - Logging shop location - Fixed Heroes for the newest version - Removed redutant plugin object - Added dev-url for CraftBukkitUpToDate - Removed redutant plugins from softdepend - Fixed a bug when the player interacts with a shop with a sign in hand
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;
|
|
}
|
|
}
|