Example #1
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);
  }
Example #2
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;
 }