Skip to content

Commit eb52b88

Browse files
committed
Add more javadoc.
1 parent 627df85 commit eb52b88

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

src/main/java/de/craften/plugins/bkcommandapi/Command.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,59 @@
22

33
import java.lang.annotation.*;
44

5+
/**
6+
* Annotation for methods in a {@link CommandHandler} that handle commands.
7+
*/
58
@Documented
69
@Retention(RetentionPolicy.RUNTIME)
710
@Target(ElementType.METHOD)
811
public @interface Command {
12+
/**
13+
* The command.
14+
*
15+
* @return the command
16+
*/
917
String[] value() default {};
1018

19+
/**
20+
* The permission that is required to use this command.
21+
*
22+
* @return the permission that is required to use this command
23+
*/
1124
String permission() default "";
1225

26+
/**
27+
* A string describing the usage of this command.
28+
*
29+
* @return a string describing the usage of this command
30+
*/
1331
String[] usage() default {};
1432

33+
/**
34+
* The minimum number of arguments to use this command with.
35+
*
36+
* @return the minimum number of arguments to use this command with
37+
*/
1538
int min() default 0;
1639

40+
/**
41+
* The maximum number of arguments to use this command with.
42+
*
43+
* @return the maximum number of arguments to use this command with
44+
*/
1745
int max() default 0;
1846

47+
/**
48+
* Whether this command may be used from the console.
49+
*
50+
* @return whether this command may be used from the console
51+
*/
1952
boolean allowFromConsole() default false;
2053

54+
/**
55+
* A description of this command.
56+
*
57+
* @return a description of this command
58+
*/
2159
String description() default "";
2260
}

src/main/java/de/craften/plugins/bkcommandapi/SubCommandHandler.java

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,14 @@ public final boolean onCommand(CommandSender sender, org.bukkit.command.Command
100100
return false;
101101
}
102102

103-
private boolean containsAny(String[] haystack, String needle) {
103+
/**
104+
* Checks if the given array contains the given string (case insensitive).
105+
*
106+
* @param haystack array to search for the needle
107+
* @param needle string to search in the array
108+
* @return true if the string was found in the array, false if not
109+
*/
110+
private static boolean containsAny(String[] haystack, String needle) {
104111
for (String s : haystack) {
105112
if (needle.equalsIgnoreCase(s)) {
106113
return true;
@@ -173,6 +180,12 @@ private void onUsageHelpCommand(CommandSender sender, String command) {
173180
}
174181
}
175182

183+
/**
184+
* Sends the help line of the given command to the given command sender.
185+
*
186+
* @param sender command sender to send the help line to
187+
* @param command command to send the help line for
188+
*/
176189
protected void sendHelpLine(CommandSender sender, Command command) {
177190
if (command.value().length > 0) {
178191
sender.sendMessage("/" + parentCommand + " " + command.value()[0] + " - " + command.description());
@@ -181,6 +194,12 @@ protected void sendHelpLine(CommandSender sender, Command command) {
181194
}
182195
}
183196

197+
/**
198+
* Sends usage help for the given command to the given command sender.
199+
*
200+
* @param sender command sender to send the usage help to
201+
* @param command command to send the usage help for
202+
*/
184203
protected void sendUsageHelp(CommandSender sender, Command command) {
185204
sender.sendMessage(command.description());
186205
if (command.usage().length > 0) {

0 commit comments

Comments
 (0)