Skip to content

Commit 3e43e2e

Browse files
committed
clone item stacks before adding to preview GUI
1 parent 824a8df commit 3e43e2e

File tree

1 file changed

+2
-2
lines changed
  • src/main/java/pro/cloudnode/smp/bankaccounts

1 file changed

+2
-2
lines changed

src/main/java/pro/cloudnode/smp/bankaccounts/POS.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ public void delete() {
271271
* @param pos The POS
272272
*/
273273
public static void openOwnerGui(final @NotNull Player player, final @NotNull Chest chest, final @NotNull POS pos) {
274-
final @NotNull ItemStack @NotNull [] items = Arrays.stream(chest.getInventory().getStorageContents()).filter(Objects::nonNull).toArray(ItemStack[]::new);
274+
final @NotNull ItemStack @NotNull [] items = Arrays.stream(chest.getInventory().getStorageContents()).filter(Objects::nonNull).map(ItemStack::clone).toArray(ItemStack[]::new);
275275
final int extraRows = 1;
276276
final int size = extraRows * 9 + items.length + 9 - items.length % 9;
277277
final @NotNull Inventory gui = BankAccounts.getInstance().getServer().createInventory(null, size, BankAccounts.getInstance().config().posTitle(pos));
@@ -317,7 +317,7 @@ public static void openOwnerGui(final @NotNull Player player, final @NotNull Che
317317
* @param pos The POS
318318
*/
319319
public static void openBuyGui(final @NotNull Player player, final @NotNull Chest chest, final @NotNull POS pos, final @NotNull Account account) {
320-
final @NotNull ItemStack @NotNull [] items = Arrays.stream(chest.getInventory().getStorageContents()).filter(Objects::nonNull).toArray(ItemStack[]::new);
320+
final @NotNull ItemStack @NotNull [] items = Arrays.stream(chest.getInventory().getStorageContents()).filter(Objects::nonNull).map(ItemStack::clone).toArray(ItemStack[]::new);
321321
final int extraRows = 1;
322322
final int size = extraRows * 9 + items.length + 9 - items.length % 9;
323323
final @NotNull Inventory gui = BankAccounts.getInstance().getServer().createInventory(null, size, BankAccounts.getInstance().config().posTitle(pos));

0 commit comments

Comments
 (0)