private ItemStack[] getIcons() { ItemStack[] icons = new ItemStack[InventoryType.CHEST.getDefaultSize()]; for (PlayerShopOffer offer : shop.getOffers().values()) { icons[offer.getSlot()] = getIcon(offer); } return icons; }
private ItemStack getSellIcon(PlayerShopOffer offer) { ItemStack icon = new ItemStack(offer.getItem().getItemStack()); icon.setAmount(1); String priceLine = ChatColor.GRAY + getSession().getTranslator().$(ASMessageKey.SHOP_INV_ICON_SELL) + ChatColor.RED + " " + OffersUtils.getFormatedPrice(offer.getPrice()); String amountLine = ChatColor.GRAY + "x" + offer.getItem().getAmount(); String ownerLine = ChatColor.GRAY + shop.getOwnerName(); InventoryUtils.appendLore(icon, priceLine, amountLine, ownerLine); return icon; }
private ItemStack getIcon(PlayerShopOffer offer) { if (offer.getType().equals(OfferType.SELL)) { return getSellIcon(offer); } else { return getBuyIcon(offer); } }
private void handleTrade(Player player, InventoryClickEvent event, PlayerShopOffer offer) { if (offer.getType().equals(OfferType.SELL)) { if (getSession().getPermissionsProvider().has(player, ASPermissionKey.BUY_ITEMS)) { PlayerSellOfferMenu.open(this, (PlayerSellOffer) offer, player); } else { getSession().getTranslator().$(player, ASMessageKey.NO_PERMISSION); } } else { if (getSession().getPermissionsProvider().has(player, ASPermissionKey.SELL_ITEMS)) { PlayerBuyOfferMenu.open(this, (PlayerBuyOffer) offer, player); } else { getSession().getTranslator().$(player, ASMessageKey.NO_PERMISSION); } } }
public void updateIcon(int slot) { PlayerShopOffer offer = shop.getOffers().get(slot); if (offer != null) for (PlayerShopOffer o : offer.getItem().getOffers()) inventory.setItem(o.getSlot(), getIcon(o)); }