net.forthecrown.grenadier.annotations.Argument Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of grenadier-annotations Show documentation
Show all versions of grenadier-annotations Show documentation
Annotation-based command support for Grenadier
package net.forthecrown.grenadier.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Parameter annotation for command execution methods.
*
* Use this annotation if you're seeing error messages along the lines of
* {@code Argument 'arg2' is not available in the current context} As that means
* java has gotten rid of the parameter names.
*
*
* Use example:
* public void runCommand(@Argument("value") int value) {
*
* }
*
*/
@Target(ElementType.PARAMETER)
@Retention(RetentionPolicy.RUNTIME)
public @interface Argument {
/**
* Name of the argument within the {@link com.mojang.brigadier.context.CommandContext}
* @return Argument name
*/
String value() default "";
/**
* Determines if the argument is required for the command's execution. If set
* to {@code false}, then the parameter this is annotated with may be null if
* the command doesn't have the argument
*
* @return {@code true} if the argument is optional, {@code false} otherwise
*/
boolean optional() default false;
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy