//check the permissions
if (!scs.isAdminOrHasPermission(player, permCreate)) {
scce.setCancelled(true);
scce.setCause(new InsufficientPermissionException(Term.ERROR_INSUFFICIENT_PERMISSION.get()));
}
// check money
else if (cost > 0 && !scs.getBalanceHandler().hasEnough(player.getName(), cost)) {
scce.setCancelled(true);
scce.setCause(new InsufficientResourcesException(Term.ERROR_INSUFFICIENT_MONEY_CREATE.get()));
}
// check the inventory
else if (itemRemove > 0) {
int canRemove = ItemStackUtilities.countCompatibleItemStacks(player.getInventory(), shop.getItemStack(), scs.compareItemMeta(shop.getItemStack()));
if (canRemove < itemRemove) {
// cancel the event
scce.setCancelled(true);
scce.setCause(new InsufficientResourcesException(Term.ERROR_INSUFFICIENT_ITEMS_CREATE.get()));
} else {
// remove the items
ItemStackUtilities.removeFromInventory(player.getInventory(), shop.getItemStack(), itemRemove, scs.compareItemMeta(shop.getItemStack()));
}
// check if there is already a showcase
} else if (scs.getShopHandler().isShopBlock(shop.getBlock())) {
scce.setCancelled(true);
scce.setCause(new RuntimeException(Term.ERROR_ALREADY_SHOWCASE.get()));
}
// has the player to many shops
else if (scs.getShopHandler().getShopAmount(scce.getPlayer().getName()) >= Properties.maxShopAmountPerPlayer && !scs.isAdmin(scce.getPlayer())) {
scce.setCancelled(true);
scce.setCause(new RuntimeException(Term.ERROR_SHOP_LIMIT_EXCEEDED.get()));
}
// check black list item
else if ((shop instanceof SellShop && (Properties.sellBlackList == Properties.sellList.contains(shop.getItemStack().getData())))
|| (shop instanceof BuyShop && (Properties.buyBlackList == Properties.buyList.contains(shop.getItemStack().getData())))){
scce.setCancelled(true);
scce.setCause(new InsufficientPermissionException(Term.BLACKLIST_ITEM.get()));
}
// check black list block
else if (Properties.blockList.contains(shop.getBlock().getType().getData())) {
scce.setCancelled(true);
scce.setCause(new InsufficientPermissionException(Term.BLACKLIST_BLOCK.get()));
}
// check black list world
else if (Properties.blacklistedWorlds.contains(shop.getWorld())) {
scce.setCancelled(true);
scce.setCause(new InsufficientPermissionException(Term.BLACKLIST_WORLD.get()));
}
}
}