Skip to content

Commit

Permalink
clone item stacks before adding to preview GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
zefir-git committed Nov 30, 2024
1 parent 824a8df commit 3e43e2e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/pro/cloudnode/smp/bankaccounts/POS.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ public void delete() {
* @param pos The POS
*/
public static void openOwnerGui(final @NotNull Player player, final @NotNull Chest chest, final @NotNull POS pos) {
final @NotNull ItemStack @NotNull [] items = Arrays.stream(chest.getInventory().getStorageContents()).filter(Objects::nonNull).toArray(ItemStack[]::new);
final @NotNull ItemStack @NotNull [] items = Arrays.stream(chest.getInventory().getStorageContents()).filter(Objects::nonNull).map(ItemStack::clone).toArray(ItemStack[]::new);
final int extraRows = 1;
final int size = extraRows * 9 + items.length + 9 - items.length % 9;
final @NotNull Inventory gui = BankAccounts.getInstance().getServer().createInventory(null, size, BankAccounts.getInstance().config().posTitle(pos));
Expand Down Expand Up @@ -317,7 +317,7 @@ public static void openOwnerGui(final @NotNull Player player, final @NotNull Che
* @param pos The POS
*/
public static void openBuyGui(final @NotNull Player player, final @NotNull Chest chest, final @NotNull POS pos, final @NotNull Account account) {
final @NotNull ItemStack @NotNull [] items = Arrays.stream(chest.getInventory().getStorageContents()).filter(Objects::nonNull).toArray(ItemStack[]::new);
final @NotNull ItemStack @NotNull [] items = Arrays.stream(chest.getInventory().getStorageContents()).filter(Objects::nonNull).map(ItemStack::clone).toArray(ItemStack[]::new);
final int extraRows = 1;
final int size = extraRows * 9 + items.length + 9 - items.length % 9;
final @NotNull Inventory gui = BankAccounts.getInstance().getServer().createInventory(null, size, BankAccounts.getInstance().config().posTitle(pos));
Expand Down

0 comments on commit 3e43e2e

Please sign in to comment.