Examples of BuyShop


Examples of com.kellerkindt.scs.shops.BuyShop

                try {
                    maxAmount = Integer.parseInt(args[2]);
                } catch (Exception e) {}
           
            // new shop
            shop = new BuyShop(UUID.randomUUID(), owner, loc, is);
            ((BuyShop)shop).setMaxAmount(maxAmount);
           
        } else if (type.equalsIgnoreCase("basic") || type.equalsIgnoreCase("tutorial")) {
            amount = 0;
            price = 0.0;
View Full Code Here

Examples of com.kellerkindt.scs.shops.BuyShop

  @EventHandler (ignoreCancelled=true, priority=EventPriority.HIGHEST)
  public void onShowCasePlayerSellEvent(ShowCasePlayerSellEvent scpse) {
    if (scpse.verify()) {
      Player    player  = scpse.getPlayer();
      int     amount  = scpse.getQuantity();
      BuyShop    shop  = scpse.getShop();
      double    price  = shop.getPrice();
      Throwable  cause  = null;
     
 
      // fix amount
      if (amount > (shop.getMaxAmount()-shop.getAmount()) && !shop.isUnlimited()) {
        scpse.setQuantity(shop.getMaxAmount()-shop.getAmount());
        amount = scpse.getQuantity();
      }
     
      // insufficient permission
      if (!scs.canUse(player)) {
        cause = new InsufficientPermissionException(Term.ERROR_INSUFFICIENT_PERMISSION.get());
       
      }
     
      // insufficient money
      else if (!scs.getBalanceHandler().hasEnough(shop.getOwner(), amount*price)) {
        cause = new InsufficientResourcesException(Term.ERROR_INSUFFICIENT_MONEY_COSTUMER.get());
      }
 
      if (cause != null) {
        scpse.setCancelled(true);
View Full Code Here

Examples of com.kellerkindt.scs.shops.BuyShop

        if (is == null || is.getTypeId() == 0) {
          throw new MissingOrIncorrectArgumentException (Term.ITEM_MISSING.get());
        }

        // if the id already exists, the ShopHandler will set a new one
        BuyShop  shop  = new BuyShop(UUID.randomUUID(), player.getName(), null, is.clone());
       
        shop.setMaxAmount  (amount);
        shop.setUnlimited  (unlimited);
        shop.setPrice    (price);
       
        scs.msgPlayer(player, next);
        scs.addTodo(player, new Todo (player, Type.CREATE, shop, 0, null));

        return true;
View Full Code Here

Examples of com.kellerkindt.scs.shops.BuyShop

        Term.INFO_2.get(scs.formatCurrency(shop.getPrice())),
        Term.INFO_9.get(shop.getOwner())));
   
    // buy shop item
    if (shop instanceof BuyShop) {
      BuyShop shopBuy  = (BuyShop)shop;
     
      scs.msgPlayer(player, String.format("%-30s  %s",
          Term.INFO_4.get(MaterialNames.getItemName(shop.getItemStack())),
          Term.INFO_3.get(shop.isUnlimited() ? Term.INFO_UNLIMITED.get() : String.format("%d/%d", shopBuy.getAmount(), shopBuy.getMaxAmount()))));
    }
   
    // sell shop item
    else if (shop instanceof SellShop) {     
      scs.msgPlayer(player, String.format("%-30s %s",
View Full Code Here

Examples of com.kellerkindt.scs.shops.BuyShop

   * @param scle ShowCaseLimitEvent with needed information about the shop and player
   */
  @EventHandler (ignoreCancelled=true, priority=EventPriority.MONITOR)
  public void onShowCaseLimitEvent (ShowCaseLimitEvent scle) {
    if (scle.getShop() instanceof BuyShop) {
      BuyShop shop = (BuyShop)scle.getShop();
     
      shop.setMaxAmount(scle.getLimit());
      scle.setMsgSuccessfully(Term.MESSAGE_BUY_LIMIT.get(""+shop.getMaxAmount()));
    }
  }
View Full Code Here

Examples of com.kellerkindt.scs.shops.BuyShop

  @Override
  @EventHandler (ignoreCancelled=true, priority=EventPriority.MONITOR)
  public void onShowCasePlayerSellEvent(ShowCasePlayerSellEvent scpse) {
   
    Player    player  = scpse.getPlayer();
    BuyShop   shop   = scpse.getShop();
   
    int   removed = ItemStackUtilities.removeFromInventory(player.getInventory(), shop.getItemStack(), scpse.getQuantity(), scs.compareItemMeta(shop.getItemStack()));
    double  price  = removed * shop.getPrice();
   
    scs.getBalanceHandler().sub(shop.getOwner(),  price);
    scs.getBalanceHandler().add(player,       price);
   
    // add the amount that was removed
    shop.setAmount(shop.getAmount() + removed);
   
    // set successfully message
    scpse.setMsgSuccessfully(Term.MESSAGE_BUY.get(MaterialNames.getItemName(shop.getItemStack()), ""+removed, ""+price));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.