From 3837bd3c26566dbaab9f3bc59b8277557f14d097 Mon Sep 17 00:00:00 2001 From: GregF Date: Sat, 3 Aug 2024 06:59:49 +0000 Subject: [PATCH] Corrected option handling on GE interface --- .../iface/ge/GrandExchangeInterface.java | 2 +- .../global/handlers/iface/ge/StockMarket.kt | 42 ++++++++++++------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/Server/src/main/content/global/handlers/iface/ge/GrandExchangeInterface.java b/Server/src/main/content/global/handlers/iface/ge/GrandExchangeInterface.java index 853808349..9b615b305 100644 --- a/Server/src/main/content/global/handlers/iface/ge/GrandExchangeInterface.java +++ b/Server/src/main/content/global/handlers/iface/ge/GrandExchangeInterface.java @@ -112,7 +112,7 @@ public class GrandExchangeInterface extends ComponentPlugin { GrandExchangeOffer offer; GrandExchangeRecords records = GrandExchangeRecords.getInstance(player); if (index > -1 && (offer = records.getOffer(records.getOfferRecords()[index])) != null) { - StockMarket.withdraw(player, offer, slot >> 1); + StockMarket.withdraw(player, offer, slot >> 1, opcode); } return true; } diff --git a/Server/src/main/content/global/handlers/iface/ge/StockMarket.kt b/Server/src/main/content/global/handlers/iface/ge/StockMarket.kt index dd1d345d3..eba0a2435 100644 --- a/Server/src/main/content/global/handlers/iface/ge/StockMarket.kt +++ b/Server/src/main/content/global/handlers/iface/ge/StockMarket.kt @@ -98,7 +98,7 @@ class StockMarket : InterfaceListener { 209,211 -> if (openedOffer == null){ SystemLogger.logGE("[WARN] Player tried to withdraw item with null openedOffer!") return@on false - } else withdraw(player, openedOffer, (button - 209) shr 1) + } else withdraw(player, openedOffer, (button - 209) shr 1, op) 190 -> confirmOffer(player, tempOffer, openedIndex).also { return@on true } 194 -> player.interfaceManager.openChatbox(Components.OBJDIALOG_389) 203 -> abortOffer(player, openedOffer) @@ -342,7 +342,7 @@ class StockMarket : InterfaceListener { } @JvmStatic - fun withdraw(player: Player, offer: GrandExchangeOffer, index: Int) + fun withdraw(player: Player, offer: GrandExchangeOffer, index: Int, op: Int) { val item = offer.withdraw[index] if(item == null) @@ -351,20 +351,32 @@ class StockMarket : InterfaceListener { return } - if(hasSpaceFor(player, item)) - { - addItem(player, item.id, item.amount) - } - else - { - val note = item.noteChange - if(note == -1 || !hasSpaceFor(player, Item(note, item.amount))) - { - playAudio(player, Sounds.GE_TRADE_ERROR_4039) - sendMessage(player, "You do not have enough room in your inventory.") - return + when (op) { + // withdraw notes + 155 -> { + val note = item.noteChange + if (note == -1) { + sendMessage(player, "This item cannot be noted") + return + } + if (hasSpaceFor(player, Item(note, item.amount))) { + addItem(player, note, item.amount) + } else { + playAudio(player, Sounds.GE_TRADE_ERROR_4039) + sendMessage(player, "You do not have enough room in your inventory.") + return + } + } + // withdraw items + 196 -> { + if (hasSpaceFor(player, item)) { + addItem(player, item.id, item.amount) + } else { + playAudio(player, Sounds.GE_TRADE_ERROR_4039) + sendMessage(player, "You do not have enough room in your inventory.") + return + } } - else addItem(player, note, item.amount) } offer.withdraw[index] = null