/** * Attempts to create a new shop object based on this block * * @param block the block to consider * @param plugin The active PhysicalShop plugin * @return null if block is not sign or said sign is invalid, otherwise a new associated {@link * Shop} for this block */ public static Shop getShop(final Block block, final PhysicalShop plugin) { if (block == null) return null; if (block.getType() != SIGN_POST && block.getType() != WALL_SIGN) return null; final Sign sign = (Sign) block.getState(); if (sign == null) return null; final String ownerName = Shop.getOwnerName(sign.getLines()); try { if (block.getRelative(DOWN).getType() == CHEST) return new ChestShop(sign, plugin); else if (ownerName.equalsIgnoreCase(plugin.getConfig().getString(SERVER_SHOP))) return new Shop(sign, plugin); else return null; } catch (final InvalidSignException e) { return null; } }
/** * This assumes player does NOT have admin access * * @param player Player to check for access * @param shop Shop to check for access * @param plugin The current instance of PhysicalShop * @return true if the player has permission for the shop */ public static boolean hasAccess(final String player, final Shop shop, final PhysicalShop plugin) { return shop == null || (!plugin.getConfig().getString(SERVER_SHOP).equals(shop.getOwnerName()) && shop.isSmartOwner(player, plugin)); }