diff --git a/api/src/main/java/com/clubobsidian/dynamicgui/api/command/cloud/CloudArgument.java b/api/src/main/java/com/clubobsidian/dynamicgui/api/command/cloud/CloudArgument.java index b036802c4..a2bbeb9a8 100644 --- a/api/src/main/java/com/clubobsidian/dynamicgui/api/command/cloud/CloudArgument.java +++ b/api/src/main/java/com/clubobsidian/dynamicgui/api/command/cloud/CloudArgument.java @@ -63,6 +63,9 @@ public static CloudArgument create(@NotNull Function function) { } public T argument(@NotNull String argName) { - return this.argument(argName, false); + return this.argument(argName, false, false); } - public T argument(@NotNull String argName, boolean optional) { + public T argument(@NotNull String argName, + boolean optional, + boolean greedy) { Objects.requireNonNull(argName); - return (T) this.function.apply(new CloudData(argName, optional)); + return (T) this.function.apply(new CloudData(argName, optional, greedy)); } } diff --git a/api/src/main/java/com/clubobsidian/dynamicgui/api/command/cloud/CloudData.java b/api/src/main/java/com/clubobsidian/dynamicgui/api/command/cloud/CloudData.java index 2bf56b15d..1bf61b5c8 100644 --- a/api/src/main/java/com/clubobsidian/dynamicgui/api/command/cloud/CloudData.java +++ b/api/src/main/java/com/clubobsidian/dynamicgui/api/command/cloud/CloudData.java @@ -20,10 +20,14 @@ public class CloudData { private final String argumentName; private final boolean optional; + private final boolean greedy; - public CloudData(String argumentName, boolean optional) { + public CloudData(String argumentName, + boolean optional, + boolean greedy) { this.argumentName = argumentName; this.optional = optional; + this.greedy = greedy; } public String getArgumentName() { @@ -33,4 +37,8 @@ public String getArgumentName() { public boolean isOptional() { return this.optional; } + + public boolean isGreedy() { + return this.greedy; + } } \ No newline at end of file diff --git a/core/src/main/java/com/clubobsidian/dynamicgui/core/command/CommandRegistrarImpl.java b/core/src/main/java/com/clubobsidian/dynamicgui/core/command/CommandRegistrarImpl.java index 82770a890..bef7d2531 100644 --- a/core/src/main/java/com/clubobsidian/dynamicgui/core/command/CommandRegistrarImpl.java +++ b/core/src/main/java/com/clubobsidian/dynamicgui/core/command/CommandRegistrarImpl.java @@ -84,9 +84,9 @@ public void registerGuiAliasCommand(@NotNull String guiName, String metaKey = "command_" + argName; context.optional(argName).ifPresent(value -> { String metadataValue = EntityManager.get().isPlayer(value) ? - EntityManager.get().createPlayerWrapper(value).getName() : - String.valueOf(value); - metadata.put(metaKey, metadataValue); + EntityManager.get().createPlayerWrapper(value).getName() : + String.valueOf(value); + metadata.put(metaKey, metadataValue); }); } GuiManager.get().openGui(playerWrapper, guiName, metadata); diff --git a/parser/src/main/java/com/clubobsidian/dynamicgui/parser/gui/SimpleGuiToken.java b/parser/src/main/java/com/clubobsidian/dynamicgui/parser/gui/SimpleGuiToken.java index 757d58f20..0e32a7b46 100644 --- a/parser/src/main/java/com/clubobsidian/dynamicgui/parser/gui/SimpleGuiToken.java +++ b/parser/src/main/java/com/clubobsidian/dynamicgui/parser/gui/SimpleGuiToken.java @@ -100,10 +100,11 @@ private List loadCommandArguments(ConfigurationSection section ConfigurationSection keySec = section.getConfigurationSection(key); String type = keySec.getString("type"); boolean optional = keySec.getBoolean("optional"); + boolean greedy = keySec.getBoolean("greedy"); Optional opt = CloudArgument.fromType(type); if (opt.isPresent()) { CloudArgument arg = opt.get(); - args.add(arg.argument(keyName, optional)); + args.add(arg.argument(keyName, optional, greedy)); } else { DynamicGui.get().getLogger().error("Invalid argument type %s", type); }