From 842867c349d646656d2a6d1daaae3fcc3067881f Mon Sep 17 00:00:00 2001 From: Maxence Simon <32517160+Maxlego08@users.noreply.github.com> Date: Fri, 24 Oct 2025 13:42:54 +0200 Subject: [PATCH] Prevent adding vault items with invalid slot --- .../module/modules/vault/VaultModule.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/fr/maxlego08/essentials/module/modules/vault/VaultModule.java b/src/main/java/fr/maxlego08/essentials/module/modules/vault/VaultModule.java index 1c9b5c2b..9fe521ce 100644 --- a/src/main/java/fr/maxlego08/essentials/module/modules/vault/VaultModule.java +++ b/src/main/java/fr/maxlego08/essentials/module/modules/vault/VaultModule.java @@ -212,12 +212,22 @@ public VaultResult updateExistingVaultItem(Vault currentVault, UUID uniqueId, It @Override public VaultResult addNewItemToVault(Vault vault, UUID uniqueId, ItemStack currentItem, int quantity, int size, int totalSlots, int slot) { - int nextSlot = vault.getNextSlot() + ((vault.getVaultId() - 1) * size); - if (nextSlot == -1 || nextSlot >= totalSlots) { + int nextSlot = vault.getNextSlot(); + if (nextSlot == -1) { return null; } - if (slot == -1) slot = vault.getNextSlot(); + int virtualNextSlot = nextSlot + ((vault.getVaultId() - 1) * size); + if (virtualNextSlot >= totalSlots) { + return null; + } + + if (slot == -1) { + slot = nextSlot; + if (slot == -1) { + return null; + } + } VaultItem newVaultItem = new ZVaultItem(slot, currentItem, quantity); vault.getVaultItems().put(slot, newVaultItem);