Exemplo n.º 1
0
        public void offerSellItem(int inventorySlot)
        {
            Item item = p.getInventory().getSlot(inventorySlot);

            if (item != null && item.getItemId() > 0 && item.getItemAmount() > 0)
            {
                int           itemToShow = item.getItemId();
                ItemData.Item def        = item.getDefinition();

                if (def == null)
                {
                    p.getPackets().sendMessage("This item cannot be found in item definitions, please report it.");
                    return;
                }

                if (def.isNoted())
                {
                    itemToShow = ItemData.getUnNotedItem(item.getItemId());
                    if (itemToShow == item.getItemId())   // item is only noted
                    {
                        p.getPackets().sendMessage("An unnoted equivalent of this item cannot be found, please report it.");
                        return;
                    }
                    else
                    {
                        def = ItemData.forId(itemToShow); //update item def with un-noted def.. to fix price.
                    }
                }

                if (def.isPlayerBound() || (def.getPrice().getNormalPrice() == 0 && def.getPrice().getMaximumPrice() == 0 && def.getPrice().getMinimumPrice() == 0))
                { //look at unNoted item price, of a item which was previously noted.
                    p.getPackets().sendMessage("This item cannot be sold on the Grand Exchange.");
                    return;
                }

                p.getPackets().sendConfig(1109, itemToShow);
                p.getPackets().sendConfig(1110, item.getItemAmount());
                p.getPackets().sendConfig(1114, def.getPrice().getNormalPrice());
                p.getPackets().sendConfig(1116, def.getPrice().getMaximumPrice());
                p.getPackets().sendConfig(1115, def.getPrice().getMinimumPrice());
                p.getPackets().sendConfig(1111, def.getPrice().getNormalPrice());
                currentOffer = new SellOffer(item.getItemId(), item.getItemAmount(), def.getPrice().getNormalPrice(), slot, p.getLoginDetails().getUsername());
                currentOffer.setUnNotedId(item.getDefinition().isNoted() ? itemToShow : item.getItemId());
            }
        }