Corrected option handling on GE interface

This commit is contained in:
GregF 2024-08-03 06:59:49 +00:00 committed by Ryan
parent 18d5d80fba
commit 3837bd3c26
2 changed files with 28 additions and 16 deletions

View file

@ -112,7 +112,7 @@ public class GrandExchangeInterface extends ComponentPlugin {
GrandExchangeOffer offer; GrandExchangeOffer offer;
GrandExchangeRecords records = GrandExchangeRecords.getInstance(player); GrandExchangeRecords records = GrandExchangeRecords.getInstance(player);
if (index > -1 && (offer = records.getOffer(records.getOfferRecords()[index])) != null) { 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; return true;
} }

View file

@ -98,7 +98,7 @@ class StockMarket : InterfaceListener {
209,211 -> if (openedOffer == null){ 209,211 -> if (openedOffer == null){
SystemLogger.logGE("[WARN] Player tried to withdraw item with null openedOffer!") SystemLogger.logGE("[WARN] Player tried to withdraw item with null openedOffer!")
return@on false 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 } 190 -> confirmOffer(player, tempOffer, openedIndex).also { return@on true }
194 -> player.interfaceManager.openChatbox(Components.OBJDIALOG_389) 194 -> player.interfaceManager.openChatbox(Components.OBJDIALOG_389)
203 -> abortOffer(player, openedOffer) 203 -> abortOffer(player, openedOffer)
@ -342,7 +342,7 @@ class StockMarket : InterfaceListener {
} }
@JvmStatic @JvmStatic
fun withdraw(player: Player, offer: GrandExchangeOffer, index: Int) fun withdraw(player: Player, offer: GrandExchangeOffer, index: Int, op: Int)
{ {
val item = offer.withdraw[index] val item = offer.withdraw[index]
if(item == null) if(item == null)
@ -351,20 +351,32 @@ class StockMarket : InterfaceListener {
return return
} }
if(hasSpaceFor(player, item)) when (op) {
{ // withdraw notes
addItem(player, item.id, item.amount) 155 -> {
} val note = item.noteChange
else if (note == -1) {
{ sendMessage(player, "This item cannot be noted")
val note = item.noteChange return
if(note == -1 || !hasSpaceFor(player, Item(note, item.amount))) }
{ if (hasSpaceFor(player, Item(note, item.amount))) {
playAudio(player, Sounds.GE_TRADE_ERROR_4039) addItem(player, note, item.amount)
sendMessage(player, "You do not have enough room in your inventory.") } else {
return 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 offer.withdraw[index] = null