Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
public class MetaCommand extends SubCommand {

private static final List<String> SUB_COMMANDS = List.of("list", "show", "set", "remove", "add", "subtract", "switch");
private static final String META_COMMAND = "deluxemenus.meta";

public MetaCommand(@NotNull final DeluxeMenus plugin) {
super(plugin);
Expand All @@ -45,7 +46,7 @@ public MetaCommand(@NotNull final DeluxeMenus plugin) {

@Override
public void execute(@NotNull final CommandSender sender, @NotNull final List<String> arguments) {
if (!sender.isOp()) {
if (!sender.hasPermission(META_COMMAND)) {
plugin.sms(sender, Messages.NO_PERMISSION);
return;
}
Expand Down Expand Up @@ -151,7 +152,7 @@ public void execute(@NotNull final CommandSender sender, @NotNull final List<Str

@Override
public @Nullable List<String> onTabComplete(@NotNull final CommandSender sender, @NotNull final List<String> arguments) {
if (!sender.isOp() || !VersionHelper.IS_PDC_VERSION || plugin.getPersistentMetaHandler() == null) {
if (!sender.hasPermission(META_COMMAND) || !VersionHelper.IS_PDC_VERSION || plugin.getPersistentMetaHandler() == null) {
return null;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,7 @@ public void loadMenu(FileConfiguration c, String key, boolean mainConfig, final

builder.parsePlaceholdersInArguments(c.getBoolean(pre + "arguments_support_placeholders", false));
builder.parsePlaceholdersAfterArguments(c.getBoolean(pre + "parse_placeholders_after_arguments", false));
builder.enableBypassPerm(c.getBoolean(pre + "enable_open_requirements_bypass_permissions", false));

// Don't need to register the menu since it's done in the constructor
new Menu(plugin, builder.build(), items, path);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/extendedclip/deluxemenus/menu/Menu.java
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ private boolean handleOpenRequirements(final @NotNull MenuHolder holder) {
return true;
}

if (holder.getViewer() != null && this.hasOpenBypassPerm(holder.getViewer())) {
if (holder.getViewer() != null && (this.options.enableBypassPerm() && this.hasOpenBypassPerm(holder.getViewer()))) {
return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class MenuOptions {
private final boolean refresh;
private final boolean parsePlaceholdersInArguments;
private final boolean parsePlaceholdersAfterArguments;
private final boolean enableBypassPerm;

private final List<String> commands;
private final boolean registerCommands;
Expand All @@ -41,6 +42,7 @@ private MenuOptions(final @NotNull MenuOptionsBuilder builder) {
this.refresh = builder.refresh;
this.parsePlaceholdersInArguments = builder.parsePlaceholdersInArguments;
this.parsePlaceholdersAfterArguments = builder.parsePlaceholdersAfterArguments;
this.enableBypassPerm = builder.enableBypassPerm;

this.commands = builder.commands;
this.registerCommands = builder.registerCommands;
Expand Down Expand Up @@ -93,6 +95,10 @@ public boolean parsePlaceholdersAfterArguments() {
return this.parsePlaceholdersAfterArguments;
}

public boolean enableBypassPerm() {
return this.enableBypassPerm;
}

public @NotNull List<@NotNull String> commands() {
return this.commands;
}
Expand Down Expand Up @@ -134,6 +140,7 @@ public boolean registerCommands() {
.refresh(this.refresh)
.parsePlaceholdersInArguments(this.parsePlaceholdersInArguments)
.parsePlaceholdersAfterArguments(this.parsePlaceholdersAfterArguments)
.enableBypassPerm(this.enableBypassPerm)
.commands(this.commands)
.registerCommands(this.registerCommands)
.arguments(this.arguments)
Expand All @@ -155,6 +162,7 @@ public static class MenuOptionsBuilder {
private boolean refresh;
private boolean parsePlaceholdersInArguments = false;
private boolean parsePlaceholdersAfterArguments = false;
private boolean enableBypassPerm = false;

private List<String> commands = List.of();
private boolean registerCommands = false;
Expand Down Expand Up @@ -216,6 +224,11 @@ public MenuOptionsBuilder parsePlaceholdersAfterArguments(final boolean parsePla
return this;
}

public MenuOptionsBuilder enableBypassPerm(final boolean enableBypassPerm) {
this.enableBypassPerm = enableBypassPerm;
return this;
}

public MenuOptionsBuilder commands(final @NotNull List<@NotNull String> commands) {
this.commands = commands;
return this;
Expand Down
Loading