From 0ce88102ed41cad26150d953fd7e7b40733f36bb Mon Sep 17 00:00:00 2001 From: LeoDog896 Date: Tue, 9 Feb 2021 19:11:27 -0500 Subject: [PATCH] Get, has, and set argument redirects --- .../command/builder/arguments/Argument.java | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/main/java/net/minestom/server/command/builder/arguments/Argument.java b/src/main/java/net/minestom/server/command/builder/arguments/Argument.java index d71b3fc7b..f69497bf4 100644 --- a/src/main/java/net/minestom/server/command/builder/arguments/Argument.java +++ b/src/main/java/net/minestom/server/command/builder/arguments/Argument.java @@ -26,6 +26,7 @@ public abstract class Argument { private final String id; private final boolean allowSpace; private final boolean useRemaining; + private Argument redirect; private ArgumentCallback callback; @@ -188,6 +189,38 @@ public abstract class Argument { return this; } + /** + * Gets the argument this argument will redirect to. + *

+ * A non-null value means that this will redirect to that argument. + * + * @return The argument this argument will redirect to + */ + @Nullable + public Argument getRedirect() { + return redirect; + } + + /** + * Checks if an argument has a redirect. + *

+ * Mostly used to make sure there isnt an argument after. + * + * @return If this argument will redirect to an argument. + */ + public boolean hasRedirect() { + return redirect != null; + } + + /** + * Sets the redirect of this argument. + * + * @param argument The argument to set the redirect to + */ + public void setRedirect(Argument argument) { + this.redirect = argument; + } + /** * Gets if the argument has any error callback. *