Package com.kellerkindt.scs.exceptions

Examples of com.kellerkindt.scs.exceptions.InsufficientPermissionException


                return true;
            }
        }
       
        if(!scs.hasPermission(cs, permission)){
            throw new InsufficientPermissionException();
        }
       
        if(args.length < minArg){
            throw new MissingOrIncorrectArgumentException();
        }
View Full Code Here


              msg.add(Term.HELP_ADMIN_7.get());
              msg.add(Term.HELP_ADMIN_8.get());
              msg.add(Term.HELP_ADMIN_9.get());
              msg.add(Term.HELP_ADMIN_10.get());
            } else
                throw new InsufficientPermissionException();
        } else if(page.equalsIgnoreCase("2")) {
          msg.add(Term.HELP_TITLE.get("2"));
          msg.add(Term.HELP_16.get());
          msg.add(Term.HELP_11.get());
          msg.add(Term.HELP_12.get());
View Full Code Here

    public boolean execute() throws MissingOrIncorrectArgumentException, InsufficientPermissionException {
        if(errorCheck())
            return true;
       
        if(Properties.blacklistedWorlds.contains(player.getWorld().getName()))
            throw new InsufficientPermissionException(Term.BLACKLIST_WORLD.get());
               
        //Default values:
        int     amount     = 0;
        boolean    unlimited  = false;
        double     price     = 1.0;
View Full Code Here

  @Override
  @EventHandler (ignoreCancelled=true, priority=EventPriority.HIGHEST)
  public void onShowCaseInfoEvent(ShowCaseInfoEvent scie) {
    if (scie.verify() && !scs.canUse(scie.getPlayer())) {
      scie.setCancelled(true);
      scie.setCause(new InsufficientPermissionException(Term.ERROR_INSUFFICIENT_PERMISSION.get()));
    }
  }
View Full Code Here

     
      Throwable  cause  = null;
     
      if (!scs.canManage(player, shop, false)) {
        // not enough permissions
        cause  = new InsufficientPermissionException(Term.ERROR_INSUFFICIENT_PERMISSION_ADD_ITEM.get());
       
      } else if (shop instanceof DisplayShop) {
        // you cannot add items to a display shop
        cause  = new RuntimeException(Term.ERROR_ADD_ITEMS_DISPlAY.get());
       
View Full Code Here

     
      // not an admin and not having the permission to manage the shop as owner
      if (!scs.isAdmin(player) && !scs.canManage(player, shop, true)) {
        // cancel the event
        scmae.setCancelled(true);
        scmae.setCause(new InsufficientPermissionException(Term.ERROR_INSUFFICIENT_PERMISSION_ADD_MEMBER.get()));
      }
    }
  }
View Full Code Here

     
     
      //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()));
      }
    }
  }
View Full Code Here

    if (scde.verify()) {
     
      // only an admin can delete / destroy a shop
      if (!scs.isAdmin(scde.getPlayer())) {
        scde.setCancelled(true);
        scde.setCause(new InsufficientPermissionException(Term.ERROR_INSUFFICIENT_PERMISSION_DESTROY.get()));
      }
    }
  }
View Full Code Here

      Throwable  cause  = null;
     
      if (!scs.canManage(player, shop, false)) {
        // not enough permissions
        cause  = new InsufficientPermissionException(Term.ERROR_INSUFFICIENT_PERMISSION_GET_ITEM.get());
       
      } else if (shop instanceof DisplayShop) {
        // you cannot add items to a display shop
        cause  = new RuntimeException(Term.ERROR_GET_DISPLAY.get());
       
View Full Code Here

  @Override
  @EventHandler (ignoreCancelled=true, priority=EventPriority.HIGHEST)
  public void onShowCaseLimitEvent(ShowCaseLimitEvent scle) {
    if (scle.verify() && !scs.canManage(scle.getPlayer(), scle.getShop(), false)) {
      scle.setCancelled(true);
      scle.setCause(new InsufficientPermissionException(Term.ERROR_INSUFFICIENT_PERMISSION_SET_LIMIT.get()));
    }
  }
View Full Code Here

TOP

Related Classes of com.kellerkindt.scs.exceptions.InsufficientPermissionException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.