Skip to content

Commit 4b185a6

Browse files
Do not store player instance in preview
1 parent a100fe3 commit 4b185a6

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/main/java/org/maxgamer/quickshop/shop/ContainerShop.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1527,9 +1527,9 @@ public void setCurrency(@Nullable String currency) {
15271527
@Override
15281528
public void openPreview(@NotNull Player player) {
15291529
if (inventoryPreview == null) {
1530-
inventoryPreview = new InventoryPreview(plugin, getItem(), player);
1530+
inventoryPreview = new InventoryPreview(plugin, getItem().clone());
15311531
}
1532-
inventoryPreview.show();
1532+
inventoryPreview.show(player);
15331533
}
15341534

15351535
@Override

src/main/java/org/maxgamer/quickshop/shop/InventoryPreview.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
public class InventoryPreview implements Listener {
4848

4949
private final ItemStack itemStack;
50-
private final Player player;
5150
private final QuickShop plugin = QuickShop.getInstance();
5251
@Nullable
5352
private Inventory inventory;
@@ -62,10 +61,9 @@ public class InventoryPreview implements Listener {
6261
* @param player Target player.
6362
* @param plugin The plugin instance.
6463
*/
65-
public InventoryPreview(@NotNull QuickShop plugin, @NotNull ItemStack itemStack, @NotNull Player player) {
64+
public InventoryPreview(@NotNull QuickShop plugin, @NotNull ItemStack itemStack) {
6665
Util.ensureThread(false);
6766
this.itemStack = itemStack.clone();
68-
this.player = player;
6967
ItemMeta itemMeta;
7068
if (itemStack.hasItemMeta()) {
7169
itemMeta = this.itemStack.getItemMeta();
@@ -99,7 +97,7 @@ public static boolean isPreviewItem(@Nullable ItemStack stack) {
9997
/**
10098
* Open the preview GUI for player.
10199
*/
102-
public void show() {
100+
public void show(Player player) {
103101
Util.ensureThread(false);
104102
if (itemStack == null || player == null || player.isSleeping()) // Null pointer exception
105103
{

0 commit comments

Comments
 (0)