예제 #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);
  }
예제 #2
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);
  }