From 305017d5234b92d5d2676ae99b3336ed6e6b50ac Mon Sep 17 00:00:00 2001 From: CocoTheOwner Date: Thu, 12 Aug 2021 23:16:51 +0200 Subject: [PATCH] Annotate @Param & @Decree & update example --- .../com/volmit/iris/util/decree/EXAMPLE.java | 4 ++-- .../iris/util/decree/annotations/Decree.java | 17 ++++++++++++++++ .../iris/util/decree/annotations/Param.java | 20 +++++++++++++++++++ 3 files changed, 39 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/volmit/iris/util/decree/EXAMPLE.java b/src/main/java/com/volmit/iris/util/decree/EXAMPLE.java index a06e00a91..4e0b52747 100644 --- a/src/main/java/com/volmit/iris/util/decree/EXAMPLE.java +++ b/src/main/java/com/volmit/iris/util/decree/EXAMPLE.java @@ -24,11 +24,11 @@ import org.bukkit.entity.Player; public class EXAMPLE { - @Decree + @Decree() public void kick( @Param(name = "player", description = "The Player to kick from the server", aliases = "p") Player player, - @Param(name = "reason", description = "A reason to kick the player for", value = "No reason!", aliases = "r") + @Param(name = "reason", description = "A reason to kick the player for", value = "No reason!", aliases = "k") String reason) { player.kickPlayer(reason); diff --git a/src/main/java/com/volmit/iris/util/decree/annotations/Decree.java b/src/main/java/com/volmit/iris/util/decree/annotations/Decree.java index de68e7fa4..926b0fbc6 100644 --- a/src/main/java/com/volmit/iris/util/decree/annotations/Decree.java +++ b/src/main/java/com/volmit/iris/util/decree/annotations/Decree.java @@ -32,11 +32,28 @@ public @interface Decree { String NO_ALIASES = "No Aliases"; + /** + * The name of this method, which is the actual Method's name by default + */ String name() default METHOD_NAME; + /** + * The description of this command.
+ * Is {@link #DEFAULT_DESCRIPTION} by default + */ String description() default DEFAULT_DESCRIPTION; + /** + * The origin this command must come from.
+ * Must be elements of the {@link DecreeOrigin} enum
+ * By default, is {@link DecreeOrigin#BOTH}, meaning both console & player can send the command + */ DecreeOrigin origin() default DecreeOrigin.BOTH; + /** + * The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of method))
+ * Can be initialized as just a string (ex. "alias") or as an array (ex. {"alias1", "alias2"})
+ * If someone uses /plugin foo and you specify alias="f" here, /plugin f will do the exact same. + */ String[] aliases() default {NO_ALIASES}; } diff --git a/src/main/java/com/volmit/iris/util/decree/annotations/Param.java b/src/main/java/com/volmit/iris/util/decree/annotations/Param.java index 3e481618e..54ca2d67f 100644 --- a/src/main/java/com/volmit/iris/util/decree/annotations/Param.java +++ b/src/main/java/com/volmit/iris/util/decree/annotations/Param.java @@ -32,11 +32,31 @@ public @interface Param { String DEFAULT_DESCRIPTION = "No Description Provided"; + /** + * The main name of this command.
+ * Required parameter.
+ * This is what is used in game, alongside any (if specified) {@link #aliases() aliases} + */ String name(); + /** + * The description of this parameter, used in help-popups in game.
+ * The default value is {@link #DEFAULT_DESCRIPTION} + */ String description() default DEFAULT_DESCRIPTION; + /** + * The default value for this argument.
+ * The entered string is parsed to the value similarly to how commandline-text would be.
+ * Default is {@link #REQUIRED}, which indicates the variable MUST be defined. + * If you define this, the variable automatically becomes non-required. + */ String value() default REQUIRED; + /** + * The aliases of this parameter (instead of just the {@link #name() name} (if specified) or Method Name (name of method))
+ * Can be initialized as just a string (ex. "alias") or as an array (ex. {"alias1", "alias2"})
+ * If someone uses /plugin foo bar=baz and you specify alias="b" here, /plugin foo b=baz will do the exact same. + */ String[] aliases() default {NO_ALIAS}; }