From 2dff0fb953dd3e7f2a7148665b59e97b31042cd9 Mon Sep 17 00:00:00 2001 From: JustAHuman-xD <65748158+JustAHuman-xD@users.noreply.github.com> Date: Tue, 19 Nov 2024 13:42:39 -0600 Subject: [PATCH] Update SurvivalSlimefunGuide.java --- .../guide/SurvivalSlimefunGuide.java | 23 ++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java index 83e43be65f..b165ba45cc 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/implementation/guide/SurvivalSlimefunGuide.java @@ -367,10 +367,27 @@ public void openSearch(PlayerProfile profile, String input, boolean addToHistory menu.addItem(index, itemstack); menu.addMenuClickHandler(index, (pl, slot, itm, action) -> { try { - if (!isSurvivalMode()) { - pl.getInventory().addItem(slimefunItem.getItem().clone()); - } else { + if (isSurvivalMode()) { displayItem(profile, slimefunItem, true); + } else if (pl.hasPermission("slimefun.cheat.items")) { + if (sfitem instanceof MultiBlockMachine) { + Slimefun.getLocalization().sendMessage(pl, "guide.cheat.no-multiblocks"); + } else { + ItemStack clonedItem = sfitem.getItem().clone(); + + if (action.isShiftClicked()) { + clonedItem.setAmount(clonedItem.getMaxStackSize()); + } + + pl.getInventory().addItem(clonedItem); + } + } else { + /* + * Fixes #3548 - If for whatever reason, + * an unpermitted players gets access to this guide, + * this will be our last line of defense to prevent any exploit. + */ + Slimefun.getLocalization().sendMessage(pl, "messages.no-permission", true); } } catch (Exception | LinkageError x) { printErrorMessage(pl, slimefunItem, x);