Ejemplo n.º 1
0
  @Override
  public void setAmountsInventory(Inventory inventory, TEntityStatus status, StockItem item) {
    Trader trader = tNpcManager.instance().getTraderRelation(player);

    // debug info
    dB.info("Setting inventory, status: ", TEntityStatus.SELL_AMOUNTS.name().toLowerCase());

    // clear the inventory
    inventory.clear();
    for (Integer amount : item.getAmounts()) {
      // set new amount
      List<String> lore = item.getDescription(status);
      lore = Limit.loreRequest(player.getName(), item, lore, status);
      lore.addAll(new ShopSession(trader, player).getDescription("sell", item, amount));

      ItemStack itemStack = item.getItem(false, lore);
      itemStack.setAmount(amount);

      // set the lore
      ItemMeta meta = itemStack.getItemMeta();

      meta.setLore(lore);

      itemStack.setItemMeta(meta);

      // set the item
      inventory.setItem(inventory.firstEmpty(), NBTUtils.markItem(itemStack));
    }
    setUi(inventory, null, TEntityStatus.SELL_AMOUNTS);
  }
Ejemplo n.º 2
0
 // override to support item patterns
 public StockItem getItem(StockItem item, String stock) {
   for (StockItem sItem : this.stock.get(stock)) {
     if (sItem.similar(item)) {
       return sItem;
     }
   }
   return null;
 }
Ejemplo n.º 3
0
  @Override
  public void setInventory(Inventory inventory, TEntityStatus status) {
    Trader trader = tNpcManager.instance().getTraderRelation(player);

    // debug info
    dB.info("Setting inventory, status: ", status.name().toLowerCase());

    // clear the inventory
    inventory.clear();
    for (StockItem item : this.stock.get(status.asStock())) {
      if (item.getSlot() < 0) item.setSlot(inventory.firstEmpty());

      // set the lore
      List<String> lore = item.getDescription(status);
      lore = Limit.loreRequest(player.getName(), item, lore, status);
      lore.addAll(
          new ShopSession(trader, player).getDescription(status.asStock(), item, item.getAmount()));

      ItemStack itemStack = item.getItem(false, lore);

      // set the item
      inventory.setItem(item.getSlot(), NBTUtils.markItem(itemStack));
    }
    setUi(inventory, null, status);
  }
Ejemplo n.º 4
0
 // override to support item patterns
 public StockItem getItem(int slot, String stock) {
   StockItem resultItem = null;
   for (StockItem stockItem : this.stock.get(stock))
     if (stockItem.getSlot() == slot) resultItem = stockItem;
   return resultItem;
 }