Examples of ExchangeShop


Examples of com.kellerkindt.scs.shops.ExchangeShop

    // add the normal items
    amount[0] = ItemStackUtilities.addToInventory(inventory, shop.getItemStack(), amount[0]);
   
    // add the exchange items
    if (shop instanceof ExchangeShop) {
      ExchangeShop exShop = (ExchangeShop)shop;
     
      // limit by inventory size
      amount[1= MAX_INVENTORY_SIZE / 2;
     
      // limit by shop amount
      if (amount[1] > exShop.getExchangeAmount()) {
        amount[1] = exShop.getExchangeAmount();
       
      }
     
      // add the exchange items
      amount[1] = ItemStackUtilities.addToInventory(inventory, exShop.getItemStack(), amount[1]);
     
    }
   

    // add the start amount
View Full Code Here

Examples of com.kellerkindt.scs.shops.ExchangeShop

        // add the items from the shop
        notAdded = shop.getAmount() - ItemStackUtilities.addToInventory(player.getInventory(), shop.getItemStack(), shop.getAmount());
       
        // add also the items of the exchange shop
        if (shop instanceof ExchangeShop) {
          ExchangeShop shopEx = (ExchangeShop)shop;
         
          notAdded += shopEx.getExchangeAmount() - ItemStackUtilities.addToInventory(player.getInventory(), shopEx.getExchangeItemStack(), shopEx.getExchangeAmount());
        }
       
        if (notAdded > 0) {
          /*
           *  reduce the amount of this shop by the
View Full Code Here

Examples of com.kellerkindt.scs.shops.ExchangeShop

          throw new MissingOrIncorrectArgumentException (Term.ITEM_MISSING.get()+",is="+is+",ex="+ex);
        }
       

        // if the id already exists, the ShopHandler will set a new one
        ExchangeShop  shop  = new ExchangeShop(UUID.randomUUID(), player.getName(), null, is.clone(), ex.clone());
       
        shop.setAmount    (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.ExchangeShop

          Term.INFO_3.get(shop.isUnlimited() ? Term.INFO_UNLIMITED.get() : String.format("%d", shop.getAmount()))));
    }
   
    // exchange shop items + enchantments
    if (shop instanceof ExchangeShop) {
      ExchangeShop shopEx  = (ExchangeShop)shop;
     
      // normal stack
      if (shopEx.getItemStack().getEnchantments().size() > 0) {
        // just show the ItemStack
        scs.msgPlayer(player, String.format("&-30s %s",
            Term.INFO_4.get(MaterialNames.getItemName(shopEx.getItemStack())),
            Term.INFO_8.get("" + shopEx.getItemStack().getEnchantments().size())));
       
       
        // list enchantments
        for (Entry<Enchantment, Integer> entry : shopEx.getItemStack().getEnchantments().entrySet()) {
          scs.msgPlayer(player, "  - "+entry.getKey().getName() +" "+entry.getValue());
        }
       
      } else {
        // just show the ItemStack
        scs.msgPlayer(player, Term.INFO_4.get(MaterialNames.getItemName(shopEx.getItemStack())));
      }
     
      // exchange stack
      if (shopEx.getExchangeItemStack().getEnchantments().size() > 0) {
        // just show the ItemStack
        scs.msgPlayer(player, String.format("&-30s %s",
            Term.INFO_4.get(MaterialNames.getItemName(shopEx.getExchangeItemStack())),
            Term.INFO_8.get("" + shopEx.getExchangeItemStack().getEnchantments().size())));
       
       
        // list enchantments
        for (Entry<Enchantment, Integer> entry : shopEx.getExchangeItemStack().getEnchantments().entrySet()) {
          scs.msgPlayer(player, "  - "+entry.getKey().getName() +" "+entry.getValue());
        }
       
      } else {
        // just show the ItemStack
        scs.msgPlayer(player, Term.INFO_4.get(MaterialNames.getItemName(shopEx.getExchangeItemStack())));
      }
     
     
    // others enchantments
    } else if (shop.getItemStack().getEnchantments().size() > 0) {
View Full Code Here

Examples of com.kellerkindt.scs.shops.ExchangeShop

   * @param sciae  ShowCaseItemAddEvent with needed information about the shop and player
   */
  @EventHandler (ignoreCancelled=true, priority=EventPriority.MONITOR)
  public void onShowCaseItemAddEvent (ShowCaseItemAddEvent sciae) {
    Shop      shop  = sciae.getShop();
    ExchangeShop  shopEx  = shop instanceof ExchangeShop ? ((ExchangeShop)shop) : null;
    int        amount  = sciae.getAmount();
   
    if (shop.getItemStack().isSimilar(sciae.getItemStack())) {
      // add the amount
      shop.setAmount(shop.getAmount() + amount);
     
      // set the message
      sciae.setMsgSuccessfully(Term.INVENTORY_UPDATE.get(""+amount, ""+shop.getAmount()));
   
    } else if (shopEx != null && shopEx.getExchangeItemStack().isSimilar(sciae.getItemStack())) {
   
      // add the amount
      shopEx.setExchangeAmount(shopEx.getExchangeAmount() + amount);
     
      // set the message
      sciae.setMsgSuccessfully(Term.INVENTORY_UPDATE.get(""+amount, ""+shopEx.getExchangeAmount()));
    }
  }
View Full Code Here

Examples of com.kellerkindt.scs.shops.ExchangeShop

   */
  @EventHandler (ignoreCancelled=true, priority=EventPriority.MONITOR)
  public void onShowCaseItemRemoveEvent (ShowCaseItemRemoveEvent scire) {
   
    Shop      shop  = scire.getShop();
    ExchangeShop  shopEx  = shop instanceof ExchangeShop ? ((ExchangeShop)shop) : null;
    int        amount  = scire.getAmount();
   
    if (shop.getItemStack().isSimilar(scire.getItemStack())) {
     
      // add the amount
      shop.setAmount(shop.getAmount() - amount);
     
      // set the message
      scire.setMsgSuccessfully(Term.INVENTORY_UPDATE.get(""+amount, ""+shop.getAmount()));
   
    } else if (shopEx != null && shopEx.getExchangeItemStack().isSimilar(scire.getItemStack())) {
   
      // add the amount
      shopEx.setExchangeAmount(shopEx.getExchangeAmount() - amount);
     
      // set the message
      scire.setMsgSuccessfully(Term.INVENTORY_UPDATE.get(""+amount, ""+shopEx.getExchangeAmount()));
    }
  }
View Full Code Here

Examples of com.kellerkindt.scs.shops.ExchangeShop

  public void onShowCasePlayerExchangeEvent(ShowCasePlayerExchangeEvent scpee) {
   
    // TODO dude, check it ^^
   
    Player      player  = scpee.getPlayer();
    ExchangeShop  shop   = scpee.getShop();
    double      price  = shop.getPrice();
   
    int   buyAmount    = scpee.getQuantity();
    double   removeAmount  = buyAmount * price;
   
    // do not divide by 0 or less
    if (removeAmount <= 0) {
      return;
    }
   
    int removed  = ItemStackUtilities.removeFromInventory(player.getInventory(), shop.getExchangeItemStack(), (int)removeAmount, scs.compareItemMeta(shop.getExchangeItemStack()));
    int toAdd  = (int)(removed / removeAmount);
   
    // add items for that was payed
    ItemStackUtilities.addToInventory(player.getInventory(), shop.getItemStack(), toAdd);
   
    scpee.setMsgSuccessfully(Term.MESSAGE_SELL_COSTUMER.get(MaterialNames.getItemName(shop.getItemStack()), ""+removed, ""+toAdd));
  }
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.