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

Register menu arguments even if the menu does not have an open command specified #160

Open
wants to merge 1 commit into
base: main
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 @@ -561,39 +561,39 @@ public void loadMenu(FileConfiguration c, String key, boolean mainConfig) {
if (!openCommands.isEmpty()) {
builder.commands(openCommands);
builder.registerCommands(c.getBoolean(pre + "register_command", false));
}

List<String> argumentNames = new ArrayList<>();
List<RequirementList> argumentRequirements = new ArrayList<>();

if (c.contains(pre + "args")) {
// New requirements parsing
if (c.isConfigurationSection(pre + "args")) {
Set<String> mapList = c.getConfigurationSection(pre + "args").getKeys(false);
debug("found args");
for (String arg : mapList) {
debug("arg: " + arg);
// If it has requirements, add them
if (c.contains(pre + "args." + arg + ".requirements")) {
debug("arg has requirements: " + arg);
argumentRequirements.add(this.getRequirements(c, pre + "args." + arg));
}
// Always add the arg itself
argumentNames.add(arg);
List<String> argumentNames = new ArrayList<>();
List<RequirementList> argumentRequirements = new ArrayList<>();

if (c.contains(pre + "args")) {
// New requirements parsing
if (c.isConfigurationSection(pre + "args")) {
Set<String> mapList = c.getConfigurationSection(pre + "args").getKeys(false);
debug("found args");
for (String arg : mapList) {
debug("arg: " + arg);
// If it has requirements, add them
if (c.contains(pre + "args." + arg + ".requirements")) {
debug("arg has requirements: " + arg);
argumentRequirements.add(this.getRequirements(c, pre + "args." + arg));
}
// Old list parsing
} else if (c.isList(pre + "args")) {
argumentNames.addAll(c.getStringList(pre + "args"));
// Old singular item parsing
} else if (c.isString(pre + "args")) {
argumentNames.add(c.getString(pre + "args"));
// Always add the arg itself
argumentNames.add(arg);
}
// Old list parsing
} else if (c.isList(pre + "args")) {
argumentNames.addAll(c.getStringList(pre + "args"));
// Old singular item parsing
} else if (c.isString(pre + "args")) {
argumentNames.add(c.getString(pre + "args"));
}

builder.arguments(argumentNames);
builder.argumentRequirements(argumentRequirements);
builder.argumentsUsageMessage(c.getString(pre + "args_usage_message", null));
}

builder.arguments(argumentNames);
builder.argumentRequirements(argumentRequirements);
builder.argumentsUsageMessage(c.getString(pre + "args_usage_message", null));

int size = 54;
if (type == InventoryType.CHEST) {
if (!c.contains(pre + "size")) {
Expand Down
Loading