Skip to content

Commit 265b0da

Browse files
author
Simeon Kummer
committed
Skip waiting for transaction on windows that don't require it
1 parent a71b318 commit 265b0da

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

lib/plugins/inventory.js

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -631,19 +631,18 @@ function inject (bot, { hideErrors }) {
631631
if (bot.supportFeature('transactionPacketExists')) {
632632
const response = once(bot, `confirmTransaction${actionId}`)
633633
if (!window.transactionRequiresConfirmation(click)) {
634-
// Only auto-confirm for inventory window (id 0) clicks
635-
// All other window types should wait for server confirmation
636-
if (window.id === 0) {
637-
confirmTransaction(window.id, actionId, true)
634+
// For windows that don't require confirmation (like cartography table on old MC),
635+
// skip waiting for server response since it will be rejected anyway
636+
confirmTransaction(window.id, actionId, true)
637+
} else {
638+
const [success] = await withTimeout(response, WINDOW_TIMEOUT)
639+
.catch(() => {
640+
throw new Error(`Server didn't respond to transaction for clicking on slot ${slot} on window with id ${window?.id}.`)
641+
})
642+
if (!success) {
643+
throw new Error(`Server rejected transaction for clicking on slot ${slot}, on window with id ${window?.id}.`)
638644
}
639645
}
640-
const [success] = await withTimeout(response, WINDOW_TIMEOUT)
641-
.catch(() => {
642-
throw new Error(`Server didn't respond to transaction for clicking on slot ${slot} on window with id ${window?.id}.`)
643-
})
644-
if (!success) {
645-
throw new Error(`Server rejected transaction for clicking on slot ${slot}, on window with id ${window?.id}.`)
646-
}
647646
} else {
648647
await waitForWindowUpdate(window, slot)
649648
}

0 commit comments

Comments
 (0)