public void updateGEProgress(GEItem offer) { connection.SendPacket(new PacketBuilder().setId(116) .addByte((byte)offer.getSlot()) .addByte((byte)offer.getProgress()) .addUShort(offer.getDisplayItem()) .addInt(offer.getPriceEach()) .addInt(offer.getTotalAmount()) .addInt(offer.getAmountTraded()) .addInt(offer.getTotalAmount() * offer.getPriceEach()).toPacket()); }
public void abortOffer() { if (currentOffer != null) { if (currentOffer.isAborted()) { return; } Item slot1 = null; Item slot2 = null; if (currentOffer is BuyOffer) { slot1 = currentOffer.getAmountTraded() == 0 ? null : new Item(currentOffer.getItem(), currentOffer.getAmountTraded()); slot2 = currentOffer.getAmountTraded() == currentOffer.getTotalAmount() ? null : new Item(995, (currentOffer.getTotalAmount() - currentOffer.getAmountTraded()) * currentOffer.getPriceEach()); } else { slot1 = currentOffer.getAmountTraded() == currentOffer.getTotalAmount() ? null : new Item(currentOffer.getUnNotedId(), currentOffer.getTotalAmount() - currentOffer.getAmountTraded()); slot2 = currentOffer.getAmountTraded() == 0 ? null : new Item(995, (currentOffer.getAmountTraded()) * currentOffer.getPriceEach()); } Item[] items = { slot1, slot2 }; currentOffer.setSlot1(slot1); currentOffer.setSlot2(slot2); p.getPackets().sendItems(-1, -1757, 523 + currentOffer.getSlot(), items); currentOffer.setProgress(currentOffer.getAbortedBarId()); currentOffer.setAborted(true); p.getPackets().updateGEProgress(currentOffer); } }
public void updateSlotStates() { Item[] items = { currentOffer.getSlot1(), currentOffer.getSlot2() }; p.getPackets().sendItems(-1, -1757, 523 + currentOffer.getSlot(), items); /* * Deletes the offer from database completely. * Only if amount you were willing to sell/(buy?) was completed * Or you clicked abort item * And taken both items out of Slot1 and Slot2. * Otherwise it just saves how much you taken out of both slots (if anything). */ if (((currentOffer.getAmountTraded() == currentOffer.getTotalAmount()) || currentOffer.isAborted()) && currentOffer.getSlot1() == null && currentOffer.getSlot2() == null) { Server.getGrandExchange().removeOffer(currentOffer); resetInterface(); currentOffer = null; } else { Server.getGrandExchange().updateGEItemSlotsDatabase(currentOffer); } }