Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bad duplication bug #50

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
7 changes: 6 additions & 1 deletion src/main/java/io/github/sefiraat/danktech2/core/DankGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.bukkit.inventory.meta.ItemMeta;

import java.text.MessageFormat;
import java.util.Arrays;


public class DankGUI extends ChestMenu {

Expand Down Expand Up @@ -80,7 +82,10 @@ public DankGUI(DankPackInstance packInstance, ItemStack itemStack) {
}

// Don't let players shift click into the GUI to bypass the handler
addPlayerInventoryClickHandler((p, slot, item, action) -> !action.isShiftClicked());
// Also don't allow clicks on items that the pack contains; this allows for item duplication
addPlayerInventoryClickHandler((p, slot, item, action) ->
!action.isShiftClicked() && Arrays.stream(packInstance.getItems())
.noneMatch(packItem -> packItem != null && item != null && packItem.getType() == item.getType()));
setupAllItems();
}

Expand Down
9 changes: 7 additions & 2 deletions src/main/java/io/github/sefiraat/danktech2/core/TrashGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import org.bukkit.inventory.meta.ItemMeta;

import java.text.MessageFormat;
import java.util.Arrays;


public class TrashGUI extends ChestMenu {

Expand Down Expand Up @@ -56,7 +58,7 @@ public class TrashGUI extends ChestMenu {
private final TrashPack trashPack;

public TrashGUI(TrashPackInstance packInstance, ItemStack itemStack) {
super("Dank Pack - Tier " + packInstance.getTier());
super("Trash Pack - Tier " + packInstance.getTier());
this.packInstance = packInstance;
this.itemStack = itemStack;
this.trashPack = (TrashPack) SlimefunItem.getByItem(itemStack);
Expand All @@ -69,7 +71,10 @@ public TrashGUI(TrashPackInstance packInstance, ItemStack itemStack) {
}

// Don't let players shift click into the GUI to bypass the handler
addPlayerInventoryClickHandler((p, slot, item, action) -> !action.isShiftClicked());
// Also don't allow clicks on items that the pack contains; this allows for item duplication
addPlayerInventoryClickHandler((p, slot, item, action) ->
!action.isShiftClicked() && Arrays.stream(packInstance.getItems())
.noneMatch(packItem -> packItem != null && item != null && packItem.getType() == item.getType()));
setupAllItems();
}

Expand Down