public void collectSlot1(bool noted) { /* * Collect item slot */ if (currentOffer == null) { p.getPackets().sendMessage("[collectSlot1]: Nice try cheater!, If this is bug please report it."); return; } if (currentOffer.getSlot1() != null) { int itemId = currentOffer.getSlot1().getItemId(); int notedId = ItemData.getNotedItem(itemId); /* * If noted mode is active, and notedId is different then itemId, * Then noted version of this itemId exists, * So you can take out item in noted version, * Otherwise it takes it out in */ int itemWithdraw = (noted && (notedId != itemId)) ? notedId : itemId; bool stackable = ItemData.forId(itemWithdraw).isStackable(); if (noted && itemWithdraw == itemId) { p.getPackets().sendMessage("This item cannot be collected as a note."); } // stackable item [arrows, runes etc] or possibly noted item. if (stackable) { int playerInventoryItemAmount = p.getInventory().getItemAmount(itemWithdraw); int grandExchangeSlot1ItemAmountToWithdraw = currentOffer.getSlot1().getItemAmount(); if (playerInventoryItemAmount >= Inventory.MAX_ITEM_AMOUNT) { p.getPackets().sendMessage("You cannot collect anymore of this item, you have maximum of this item in inventory."); return; } //if player's inventory gold + slot2 gold is more then you can hold for that inventory item. if (((long)playerInventoryItemAmount + (long)grandExchangeSlot1ItemAmountToWithdraw) > Inventory.MAX_ITEM_AMOUNT) { grandExchangeSlot1ItemAmountToWithdraw = (Inventory.MAX_ITEM_AMOUNT - playerInventoryItemAmount); } /* * Change Slot1's amount based on how much left over * if any when added to inventory after max item amount check. */ if (p.getInventory().addItem(itemWithdraw, grandExchangeSlot1ItemAmountToWithdraw)) { currentOffer.getSlot1().setItemAmount(currentOffer.getSlot1().getItemAmount() - grandExchangeSlot1ItemAmountToWithdraw); } currentOffer.setAmountCollectedItem(currentOffer.getAmountCollectedItem() + grandExchangeSlot1ItemAmountToWithdraw); //clear the item slot if the slot's item amount is <= 0 if (currentOffer.getSlot1().getItemAmount() <= 0) { currentOffer.setSlot1(null); } } else { int amountToWithdraw = currentOffer.getSlot1().getItemAmount(); // isn't noted... and isn't stackable, withdraw as regular items for (int i = 0; i < amountToWithdraw; i++) { if (!p.getInventory().addItem(itemWithdraw)) { break; } currentOffer.getSlot1().setItemAmount(currentOffer.getSlot1().getItemAmount() - 1); currentOffer.setAmountCollectedItem(currentOffer.getAmountCollectedItem() + 1); if (currentOffer.getSlot1().getItemAmount() <= 0) { currentOffer.setSlot1(null); break; } } } updateSlotStates(); } }