Skip to content

fix: resolve item amount corruption during trade completion#41

Open
rugiaDev wants to merge 1 commit intoArtillex-Studios:masterfrom
rugiaDev:master
Open

fix: resolve item amount corruption during trade completion#41
rugiaDev wants to merge 1 commit intoArtillex-Studios:masterfrom
rugiaDev:master

Conversation

@rugiaDev
Copy link

Problem

During complete(), end() calls closeInventory() which creates a timing window
where ItemStack references returned by getItems() were mutated before
addOrDrop()'s deferred Scheduler execution, resulting in incorrect item amounts
being given to players.

Changes

  • TradeGui.getItems(): return cloned ItemStacks instead of direct inventory references
  • Trade.addOrDrop(): pre-clone items before Scheduler deferred execution to prevent timing issues
  • TradePlayer.getEmptySlots(): count partial stack slots as available to fix checkFull misbehavior

- TradeGui.getItems(): return cloned ItemStacks instead of direct inventory references
- Trade.addOrDrop(): pre-clone items before Scheduler deferred execution to prevent timing issues
- TradePlayer.getEmptySlots(): count partial stack slots as available to fix checkFull misbehavior

During complete(), closeInventory() called by end() and the deferred Scheduler execution
created a timing window where ItemStack amounts were mutated before being given to players
@rugiaDev rugiaDev closed this Mar 21, 2026
@rugiaDev rugiaDev reopened this Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant