Skip to content

Commit

Permalink
improve: copy MerchantRecipe of TradeCause
Browse files Browse the repository at this point in the history
StockEvents are called on different threads, so we need to copy MerchantRecipe to avoid unexpected changes.
  • Loading branch information
Siroshun09 committed Apr 28, 2024
1 parent 51209f5 commit 6a568bb
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ private static boolean trade0(@NotNull Player trader, @NotNull AbstractVillager
}

var stockHolder = BoxAPI.api().getBoxPlayerMap().get(trader).getCurrentStockHolder();
var cause = new TradeCause(trader, merchantOffer);
var cause = new TradeCause(trader, new MerchantRecipe(merchantOffer));

if (stockHolder.decreaseIfPossible(ingredientMap, cause)) {
var resultBukkit = merchantOffer.getResult();
Expand Down

0 comments on commit 6a568bb

Please sign in to comment.