Skip to content

Commit eb7d287

Browse files
committed
Update code references
1 parent d6abfcf commit eb7d287

File tree

71 files changed

+620
-592
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+620
-592
lines changed

docs/en/annotations/annotations.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,37 @@ This page outlines in detail the list of all annotations that the CommandAPI's a
1414

1515
The `@Command` annotation is used to declare a command. The parameter is the name of the command that will be registered.
1616

17-
<<< @/../reference-code/src/main/java/annotations/WarpCommand.java#declareCommand
17+
<<< @/../reference-code/bukkit/src/main/java/annotations/WarpCommand.java#declareCommand
1818

1919
### `@Alias({...})`
2020

2121
The `@Alias` annotation is used to declare a list of aliases for a command. The parameter is a list of aliases which can be used for the command.
2222

23-
<<< @/../reference-code/src/main/java/annotations/aliasClassExample/TeleportCommand.java#aliasClassExample
23+
<<< @/../reference-code/bukkit/src/main/java/annotations/aliasClassExample/TeleportCommand.java#aliasClassExample
2424

2525
### `@Permission("permissionNode")`
2626

2727
The `@Permission` annotation is used to add a permission node to a command. Users that want to run this command must have this permission. The parameter is the permission node required to run the command.
2828

29-
<<< @/../reference-code/src/main/java/annotations/permissionClassExample/TeleportCommand.java#permissionClassExample
29+
<<< @/../reference-code/bukkit/src/main/java/annotations/permissionClassExample/TeleportCommand.java#permissionClassExample
3030

3131
### `@NeedsOp`
3232

3333
The `@NeedsOp` annotation is used to indicate that a command needs to have operator privileges to run it. This annotation has no parameters.
3434

35-
<<< @/../reference-code/src/main/java/annotations/needsOpClassExample/TeleportCommand.java#needsOpClassExample
35+
<<< @/../reference-code/bukkit/src/main/java/annotations/needsOpClassExample/TeleportCommand.java#needsOpClassExample
3636

3737
### `@Help("Full description")`
3838

3939
The `@Help` annotation is used to add a help topic to a command. This annotation can take two forms:
4040

4141
A simple form which just uses a string which is used as the full description for a command:
4242

43-
<<< @/../reference-code/src/main/java/annotations/helpClassExample/TeleportCommand.java#helpClassExample
43+
<<< @/../reference-code/bukkit/src/main/java/annotations/helpClassExample/TeleportCommand.java#helpClassExample
4444

4545
A form with two parameters `value` and `shortDescription`, to provide the full description (`value`) and short description (`shortDescription`) content for a command:
4646

47-
<<< @/../reference-code/src/main/java/annotations/shortHelpClassExample/TeleportCommand.java#shortHelpClassExample
47+
<<< @/../reference-code/bukkit/src/main/java/annotations/shortHelpClassExample/TeleportCommand.java#shortHelpClassExample
4848

4949
## Annotations that go on methods
5050

@@ -54,27 +54,27 @@ To use annotations on methods, **methods must be static**.
5454

5555
The `@Default` annotation indicates that the method is _not_ a subcommand. This acts in a similar way to regular Bukkit commands. Commands with the `@Default` annotation can be used to run the main code when the command named with the `@Command` annotation is stated, such as the following:
5656

57-
<<< @/../reference-code/src/main/java/annotations/DefaultMethodExample.java#defaultMethodExample
57+
<<< @/../reference-code/bukkit/src/main/java/annotations/DefaultMethodExample.java#defaultMethodExample
5858

5959
The `@Default` annotation does not mean that the command can't have arguments! Arguments can still be used and declared as shown:
6060

61-
<<< @/../reference-code/src/main/java/annotations/DefaultMethodExample.java#defaultWithArgsMethodExample
61+
<<< @/../reference-code/bukkit/src/main/java/annotations/DefaultMethodExample.java#defaultWithArgsMethodExample
6262

6363
### `@Subcommand`
6464

6565
The `@Subcommand` simply tells the CommandAPI that the declared method is a subcommand. This acts in a similar way to the regular CommandAPI's `.withSubcommand()` method. The subcommand annotation can take in a single string which is the name of the subcommand:
6666

67-
<<< @/../reference-code/src/main/java/annotations/SubcommandMethodExample.java#subcommandMethodExample
67+
<<< @/../reference-code/bukkit/src/main/java/annotations/SubcommandMethodExample.java#subcommandMethodExample
6868

6969
Or, it can take in a list of strings which represent the _aliases_ that can also be used for the declared subcommand:
7070

71-
<<< @/../reference-code/src/main/java/annotations/SubcommandMethodExample.java#subcommandAliasesMethodExample
71+
<<< @/../reference-code/bukkit/src/main/java/annotations/SubcommandMethodExample.java#subcommandAliasesMethodExample
7272

7373
### `@Permission`
7474

7575
The `@Permission` annotation can also be used on methods to indicate that a permission is required to execute a command.
7676

77-
<<< @/../reference-code/src/main/java/annotations/PermissionMethodExample.java#permissionMethodExample
77+
<<< @/../reference-code/bukkit/src/main/java/annotations/PermissionMethodExample.java#permissionMethodExample
7878

7979
### `@NeedsOp`
8080

@@ -95,7 +95,7 @@ $$\begin{align}
9595

9696
For example, we use `@AStringArgument` to indicate that this command takes a `StringArgument` as its first parameter:
9797

98-
<<< @/../reference-code/src/main/java/annotations/ParameterExample.java#simpleParameterExample
98+
<<< @/../reference-code/bukkit/src/main/java/annotations/ParameterExample.java#simpleParameterExample
9999

100100
- **The name of the argument (referred to as "nodeName" in the normal CommandAPI system) is the name of the variable assigned to the parameter.** In the above code, this means that the name of the argument is `warpName`.
101101

@@ -107,18 +107,18 @@ Certain argument annotations have extra parameters that can be supplied to provi
107107

108108
The following numerical arguments can take both a `min` and `max` value. Both of these are completely optional. This indicates the range of values (inclusive) that is valid for this argument. For example:
109109

110-
<<< @/../reference-code/src/main/java/annotations/ParameterExample.java#numericalParameterExample
110+
<<< @/../reference-code/bukkit/src/main/java/annotations/ParameterExample.java#numericalParameterExample
111111

112112
#### Literal arguments
113113

114114
Both the `LiteralArgument` and `MultiLiteralArgument` can be used. When these are used, the name of the variable assigned to the parameter is _ignored_ and not used as the argument's name.
115115

116116
For the `@ALiteralArgument` annotation, the parameter is the literal to be used for the command. For the `@AMultiLiteralArgument`, the parameter can be an array of multiple literals to use:
117117

118-
<<< @/../reference-code/src/main/java/annotations/ParameterExample.java#literalParameterExample
118+
<<< @/../reference-code/bukkit/src/main/java/annotations/ParameterExample.java#literalParameterExample
119119

120120
#### Other arguments
121121

122122
The `LocationArgument`, `Location2DArgument`, `EntitySelectorArgument` and `ScoreHolderArgument` can all take an extra parameter in their constructors. As a result, the annotation-equivalent of these arguments also allow you to provide the parameter in the annotation:
123123

124-
<<< @/../reference-code/src/main/java/annotations/ParameterExample.java#otherParameterExample
124+
<<< @/../reference-code/bukkit/src/main/java/annotations/ParameterExample.java#otherParameterExample

docs/en/annotations/intro.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,38 +43,38 @@ Let's say we're writing a plugin with the capability to create warps to places o
4343

4444
Using the regular CommandAPI, this is one way we can create this command. In the code below, we use StringArguments to represent the warp names. To teleport to a warp, we also populate it with suggestions (deferred so it updates), and also use a subcommand to represent `/warp create`:
4545

46-
<<< @/../reference-code/src/main/java/annotations/Intro.java#legacyExample
46+
<<< @/../reference-code/bukkit/src/main/java/annotations/Intro.java#legacyExample
4747

4848
Seems fairly straightforward, given everything else covered in this documentation. Now let's compare it to using annotations!
4949

5050
### Warp command (with annotations)
5151

5252
I think it's best to show the example and explain it afterwards:
5353

54-
<<< @/../reference-code/src/main/java/annotations/WarpCommand.java#annotationsExample
54+
<<< @/../reference-code/bukkit/src/main/java/annotations/WarpCommand.java#annotationsExample
5555

56-
<<< @/../reference-code/src/main/java/annotations/Intro.java#annotationsRegisterExample
56+
<<< @/../reference-code/bukkit/src/main/java/annotations/Intro.java#annotationsRegisterExample
5757

5858
As we can see, the code certainly _looks_ very different to the normal registration method. Let's take it apart piece by piece to see what exactly is going on here.
5959

6060
#### Command declaration
6161

62-
<<< @/../reference-code/src/main/java/annotations/WarpCommand.java#declareCommand
62+
<<< @/../reference-code/bukkit/src/main/java/annotations/WarpCommand.java#declareCommand
6363

6464
Firstly, we declare our command `warp`. To do this, we use the `@Command` annotation and simply state the name of the command in the annotation. This annotation is attached to the class `WarpCommand`, which indicates that the whole class `WarpCommand` will be housing our command.
6565

6666
The annotation framework is designed in such a way that an entire command is represented by a single class. This provides a more modular approach to command declaration that allows you to easily contain the methods of a command in one location.
6767

6868
#### Default command
69-
<<< @/../reference-code/src/main/java/annotations/WarpCommand.java#defaultExample
69+
<<< @/../reference-code/bukkit/src/main/java/annotations/WarpCommand.java#defaultExample
7070

7171
Here, declare the main command implementation using the `@Default` annotation. The `@Default` annotation informs the CommandAPI that the method it is attached to does not have any subcommands. This is effectively the same as registering a regular command without using `.withSubcommand()`.
7272

7373
Here, we simply write what happens when no arguments are run (i.e. the user just runs `/warp` on its own). As such, we don't include any parameters to our method.
7474

7575
#### Default command (again!)
7676

77-
<<< @/../reference-code/src/main/java/annotations/WarpCommand.java#anotherDefaultExample
77+
<<< @/../reference-code/bukkit/src/main/java/annotations/WarpCommand.java#anotherDefaultExample
7878

7979
We also have a second `@Default` annotated method, which handles our `/warp <warp>` command. Because this isn't a subcommand (the warp to teleport to is not a subcommand, it's an argument), we're still using the `@Default` annotation. In this method, we include an argument with this command by using the `@AStringArgument` annotation. This argument uses the `StringArgument` class, and the name of this argument is "warpName", which is extracted from the name of the variable. Simply put, **the Annotation for an argument is A** followed by the name of the argument. This is synonymous with using the following:
8080

@@ -88,14 +88,14 @@ The second argument is a `String` object, which represents the result of our arg
8888

8989
#### Subcommand
9090

91-
<<< @/../reference-code/src/main/java/annotations/WarpCommand.java#subcommandExample
91+
<<< @/../reference-code/bukkit/src/main/java/annotations/WarpCommand.java#subcommandExample
9292

9393
Lastly, we declare a subcommand to allow us to run `/warp create <name>`. To do this, we simply use the `@Subcommand` annotation. In this example, we also apply a permission node that is required to run the command by using the `@Permission` annotation. The rest is fairly straight forward - we declare an argument, in this case it's another `StringArgument` , so we use `@AStringArgument` and then declare everything else in a similar fashion to the default command executor.
9494

9595
#### Registering the command
9696

9797
Registering the command is fairly simple and is a one-liner:
9898

99-
<<< @/../reference-code/src/main/java/annotations/Intro.java#annotationsRegisterExample
99+
<<< @/../reference-code/bukkit/src/main/java/annotations/Intro.java#annotationsRegisterExample
100100

101101
This line can be placed in your `onEnable()` or `onLoad()` method like you were registering a normal command.

docs/en/annotations/registration.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ CommandAPI.registerCommand(className)
1616

1717
Say we have a simple command `/warp` that is defined as follows:
1818

19-
<<< @/../reference-code/src/main/java/annotations/WarpCommand.java#annotationsExample
19+
<<< @/../reference-code/bukkit/src/main/java/annotations/WarpCommand.java#annotationsExample
2020

2121
We can register this in our `onLoad()` method so we can use this command from within Minecraft functions:
2222

23-
<<< @/../reference-code/src/main/java/annotations/Registration.java#registerCommand
23+
<<< @/../reference-code/bukkit/src/main/java/annotations/Registration.java#registerCommand
2424

2525
::::

docs/en/create-commands/aliases.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ In this example, we register the command `/getpos` that returns the command send
1616

1717
:::tabs
1818
===Java
19-
<<< @/../reference-code/src/main/java/createcommands/Aliases.java#aliasesExample
19+
<<< @/../reference-code/bukkit/src/main/java/createcommands/Aliases.java#aliasesExample
2020
===Kotlin
21-
<<< @/../reference-code/src/main/kotlin/createcommands/Aliases.kt#aliasesExample
21+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/Aliases.kt#aliasesExample
2222
===Kotlin DSL
23-
<<< @/../reference-code/src/main/kotlin/createcommands/Aliases.kt#aliasesExampleDSL
23+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/Aliases.kt#aliasesExampleDSL
2424
:::
2525

2626
::::

docs/en/create-commands/arguments/arguments.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,29 +32,29 @@ The CommandAPI is very flexible when it comes to registering arguments, and lets
3232

3333
:::tabs
3434
===Java
35-
<<< @/../reference-code/src/main/java/createcommands/arguments/Arguments.java#registerArgumentsExample
35+
<<< @/../reference-code/bukkit/src/main/java/createcommands/arguments/Arguments.java#registerArgumentsExample
3636
===Kotlin
37-
<<< @/../reference-code/src/main/kotlin/createcommands/arguments/Arguments.kt#registerArgumentsExample
37+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/arguments/Arguments.kt#registerArgumentsExample
3838
===Kotlin DSL
39-
<<< @/../reference-code/src/main/kotlin/createcommands/arguments/Arguments.kt#registerArgumentsExampleDSL
39+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/arguments/Arguments.kt#registerArgumentsExampleDSL
4040
:::
4141

4242
:::tabs
4343
===Java
44-
<<< @/../reference-code/src/main/java/createcommands/arguments/Arguments.java#registerArgumentsVarargExample
44+
<<< @/../reference-code/bukkit/src/main/java/createcommands/arguments/Arguments.java#registerArgumentsVarargExample
4545
===Kotlin
46-
<<< @/../reference-code/src/main/kotlin/createcommands/arguments/Arguments.kt#registerArgumentsVarargExample
46+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/arguments/Arguments.kt#registerArgumentsVarargExample
4747
===Kotlin DSL
48-
<<< @/../reference-code/src/main/kotlin/createcommands/arguments/Arguments.kt#registerArgumentsVarargExampleDSL
48+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/arguments/Arguments.kt#registerArgumentsVarargExampleDSL
4949
:::
5050

5151
:::tabs
5252
===Java
53-
<<< @/../reference-code/src/main/java/createcommands/arguments/Arguments.java#registerArgumentsListExample
53+
<<< @/../reference-code/bukkit/src/main/java/createcommands/arguments/Arguments.java#registerArgumentsListExample
5454
===Kotlin
55-
<<< @/../reference-code/src/main/kotlin/createcommands/arguments/Arguments.kt#registerArgumentsListExample
55+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/arguments/Arguments.kt#registerArgumentsListExample
5656
===Kotlin DSL
57-
<<< @/../reference-code/src/main/kotlin/createcommands/arguments/Arguments.kt#registerArgumentsListExampleDSL
57+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/arguments/Arguments.kt#registerArgumentsListExampleDSL
5858
:::
5959

6060
## Argument Casting
@@ -63,11 +63,11 @@ To access arguments, they have to be casted to the type that the argument repres
6363

6464
:::tabs
6565
===Java
66-
<<< @/../reference-code/src/main/java/createcommands/arguments/Arguments.java#argumentCastExample
66+
<<< @/../reference-code/bukkit/src/main/java/createcommands/arguments/Arguments.java#argumentCastExample
6767
===Kotlin
68-
<<< @/../reference-code/src/main/kotlin/createcommands/arguments/Arguments.kt#argumentCastExample
68+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/arguments/Arguments.kt#argumentCastExample
6969
===Kotlin DSL
70-
<<< @/../reference-code/src/main/kotlin/createcommands/arguments/Arguments.kt#argumentCastExampleDSL
70+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/arguments/Arguments.kt#argumentCastExampleDSL
7171
:::
7272

7373
The type to cast each argument (declared in the `dev.jorel.commandapi.arguments` package) is listed below:

docs/en/create-commands/arguments/command-arguments.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ This is how these commands are implemented:
109109

110110
:::tabs
111111
===Java
112-
<<< @/../reference-code/src/main/java/createcommands/arguments/CommandArguments.java#getArgExample
112+
<<< @/../reference-code/bukkit/src/main/java/createcommands/arguments/CommandArguments.java#getArgExample
113113
===Kotlin
114-
<<< @/../reference-code/src/main/kotlin/createcommands/arguments/CommandArguments.kt#getArgExample
114+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/arguments/CommandArguments.kt#getArgExample
115115
:::
116116

117117
::::
@@ -168,9 +168,9 @@ We want to find out which entity selector is being used when the command is exec
168168

169169
:::tabs
170170
===Java
171-
<<< @/../reference-code/src/main/java/createcommands/arguments/CommandArguments.java#getRawExample
171+
<<< @/../reference-code/bukkit/src/main/java/createcommands/arguments/CommandArguments.java#getRawExample
172172
===Kotlin
173-
<<< @/../reference-code/src/main/kotlin/createcommands/arguments/CommandArguments.kt#getRawExample
173+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/arguments/CommandArguments.kt#getRawExample
174174
:::
175175

176176
::::
@@ -229,9 +229,9 @@ Here, we don't actually want to cast the argument, so we use unsafe arguments to
229229

230230
:::tabs
231231
===Java
232-
<<< @/../reference-code/src/main/java/createcommands/arguments/CommandArguments.java#getUncheckedExample
232+
<<< @/../reference-code/bukkit/src/main/java/createcommands/arguments/CommandArguments.java#getUncheckedExample
233233
===Kotlin
234-
<<< @/../reference-code/src/main/kotlin/createcommands/arguments/CommandArguments.kt#getUncheckedExample
234+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/arguments/CommandArguments.kt#getUncheckedExample
235235
:::
236236

237237
::::
@@ -290,9 +290,9 @@ To visualize this, we want to implement the command from [Access arguments by no
290290

291291
:::tabs
292292
===Java
293-
<<< @/../reference-code/src/main/java/createcommands/arguments/CommandArguments.java#getByArgumentExample
293+
<<< @/../reference-code/bukkit/src/main/java/createcommands/arguments/CommandArguments.java#getByArgumentExample
294294
===Kotlin
295-
<<< @/../reference-code/src/main/kotlin/createcommands/arguments/CommandArguments.kt#getByArgumentExample
295+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/arguments/CommandArguments.kt#getByArgumentExample
296296
:::
297297

298298
::::

docs/en/create-commands/arguments/listed-arguments.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ Let's also say that in our implementation of this command, we don't actually per
3131

3232
:::tabs
3333
===Java
34-
<<< @/../reference-code/src/main/java/createcommands/arguments/ListedArguments.java#listedArgumentsExample
34+
<<< @/../reference-code/bukkit/src/main/java/createcommands/arguments/ListedArguments.java#listedArgumentsExample
3535
===Kotlin
36-
<<< @/../reference-code/src/main/kotlin/createcommands/arguments/ListedArguments.kt#listedArgumentsExample
36+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/arguments/ListedArguments.kt#listedArgumentsExample
3737
===Kotlin DSL
38-
<<< @/../reference-code/src/main/kotlin/createcommands/arguments/ListedArguments.kt#listedArgumentsExampleDSL
38+
<<< @/../reference-code/bukkit/src/main/kotlin/createcommands/arguments/ListedArguments.kt#listedArgumentsExampleDSL
3939
:::
4040

4141
In this scenario, the argument `<value>` is not present in the [`CommandArguments args`](./command-arguments) for the executor.

0 commit comments

Comments
 (0)