Skip to content

Commit

Permalink
Merge pull request #160 from HelpChat/issue/137
Browse files Browse the repository at this point in the history
Register menu arguments even if the menu does not have an open command specified
  • Loading branch information
BlitzOffline authored Jan 2, 2025
2 parents abd23c9 + 3a838fa commit 813a1cb
Showing 1 changed file with 27 additions and 27 deletions.
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

0 comments on commit 813a1cb

Please sign in to comment.