Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/main/java/fr/maxlego08/menu/inventory/VInventory.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ public ItemButton addItem(boolean inPlayerInventory, int slot, ItemStack itemSta
return null;
}

ItemStack displayStack = itemStack.clone();

if (Configuration.enableAntiDupe && enableAntiDupe) {
itemStack = this.plugin.getDupeManager().protectItem(itemStack);
displayStack = this.plugin.getDupeManager().protectItem(displayStack);
}

ItemButton button = new ItemButton(itemStack, slot, inPlayerInventory, this);
Expand All @@ -130,11 +132,11 @@ public ItemButton addItem(boolean inPlayerInventory, int slot, ItemStack itemSta
if (inPlayerInventory) {

this.playerInventoryItems.put(slot, button);
if (!needCancel) this.player.getInventory().setItem(slot, itemStack);
if (!needCancel) this.player.getInventory().setItem(slot, displayStack);
} else {

this.items.put(slot, button);
if (!needCancel) this.inventory.setItem(slot, itemStack);
if (!needCancel) this.inventory.setItem(slot, displayStack);
Comment on lines 117 to +139
Copy link

Copilot AI May 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ItemButton is still constructed with the original itemStack, but the inventory slot is populated with displayStack (potentially dupe-protected). This creates a mismatch where itemButton.getDisplayItem() no longer reflects what is actually displayed/sent. In particular, InventoryListener implementations (e.g. PacketEvents listeners) use itemButton.getDisplayItem() to send items via packets when needCancel is true, which would bypass the anti-dupe protection you just applied to displayStack. Construct the ItemButton using the same stack that will be displayed (e.g., displayStack), or otherwise ensure the protected stack is what listeners and packet sends will use.

Copilot uses AI. Check for mistakes.
}
return button;
}
Expand Down
Loading