コード例 #1
0
 private ItemStack[] getIcons() {
   ItemStack[] icons = new ItemStack[InventoryType.CHEST.getDefaultSize()];
   for (PlayerShopOffer offer : shop.getOffers().values()) {
     icons[offer.getSlot()] = getIcon(offer);
   }
   return icons;
 }
コード例 #2
0
 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;
 }
コード例 #3
0
 private ItemStack getIcon(PlayerShopOffer offer) {
   if (offer.getType().equals(OfferType.SELL)) {
     return getSellIcon(offer);
   } else {
     return getBuyIcon(offer);
   }
 }
コード例 #4
0
 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);
     }
   }
 }
コード例 #5
0
 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));
 }