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] Add permission check to SF Search in cheat mode #4266

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -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 (slimefunItem instanceof MultiBlockMachine) {
Slimefun.getLocalization().sendMessage(pl, "guide.cheat.no-multiblocks");
} else {
ItemStack clonedItem = slimefunItem.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);
Expand Down
Loading