コード例 #1
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;
 }
コード例 #2
0
 @Override
 public void onClick(Player player, InventoryClickEvent event) {
   if (event.getCurrentItem() != null && !event.getCurrentItem().getType().equals(Material.AIR)) {
     if (event.getRawSlot() <= event.getSlot()) {
       int slot = event.getSlot();
       PlayerShopOffer offer = shop.getOffers().get(slot);
       if (offer != null) {
         if (event.isLeftClick()) {
           if (player.getName().equalsIgnoreCase(shop.getOwnerName())) {
             handleOfferEdit(player, event, offer);
           } else {
             handleTrade(player, event, offer);
           }
         } else if (event.isRightClick()) {
           if (getSession().getPermissionsProvider().has(player, ASPermissionKey.MANAGER)) {
             handleOfferEdit(player, event, offer);
           }
         }
       }
     }
   }
 }