You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+36-32Lines changed: 36 additions & 32 deletions
Original file line number
Diff line number
Diff line change
@@ -1,11 +1,10 @@
1
1
# CommandCore
2
2
CommandCore is a simple, yet powerful command framework for the Spigot API.
3
-
4
3
## Installation
5
4
**Java 8 or higher is required**
6
5
7
-
### 1) Installing to your local .m2 repo
8
-
**If you are using JitPack, you can skip this step.**
6
+
### 1) Install to your local .m2 repo
7
+
> If you are using JitPack, you can skip this step.
9
8
10
9
Clone this repository onto your local computer and run the command `mvn clean install` in that directory.
11
10
This will install CommandCore onto your local .m2 folder, so you can use the dependency.
@@ -49,48 +48,44 @@ Finally, add the maven shade plugin to shade in CommandCore
49
48
50
49
## Usage
51
50
### 1) Initialize CommandCore in your plugin
51
+
52
52
```java
53
+
importcom.datasiqn.commandcore.CommandCore;
54
+
53
55
publicfinalclassMyPluginextendsJavaPlugin {
54
-
@Override
55
-
publicvoidonEnable() {
56
-
// Init CommandCore
57
-
CommandCore.init(this, "myrootcommand");
58
-
// ...
59
-
}
56
+
@Override
57
+
publicvoidonEnable() {
58
+
// Init CommandCore
59
+
CommandCore.init(this, "myrootcommand");
60
+
// ...
61
+
}
60
62
}
61
63
```
62
64
Using the static method `CommandCore.init(...)` initializes CommandCore. After doing this, you can access the instance from anywhere by using `CommandCore.getInstance()`
The `CommandBuilder` is what you use create commands.
91
88
92
-
The constructor argument tells CommandCore that only `Player`s may execute this command and won't let other senders execute it (command blocks, the console, etc.).
93
-
94
89
On the 5th line, we use a `.executes` call. This tells CommandCore to execute whatever is in the lambda when we run the command with no arguments.
95
90
96
91
On the next line, we make a `.then` call. It adds another 'branch' to the command 'tree'. You can think of the entire command as a tree, with the `CommandBuilder` as the main trunk. Any extra `.then` calls creates another branch, or path, that the user can go down.
@@ -101,11 +96,12 @@ Notice how the literal `CommandNode` doesn't have an `.executes` call. This tell
101
96
102
97
On the next line, we create a new branch under the literal. This time, it is an argument. An argument is any string that the argument type can understand. In this case, we give it an argument type of `PLAYER`. This means that CommandCore will suggest us player names.
103
98
104
-
After that, we have a `.executes` call. This gets executed when we have typed that entire branch out. (ex. `/... player DatAsiqn`).
99
+
After that, we have a `.requiresPlayer` call. This tells CommandCore that the current node (the PLAYER argument) requires a player to use it. If, for example, the console sends it, CommandCore will not execute the command and instead give the user an error.
100
+
Finally, we have a `.executes` call. This gets executed when we have typed that entire branch out. (ex. `/... player DatAsiqn`).
105
101
106
102
The next line is adding another literal onto the main trunk (notice the indentation). This literal is less complicated than the last, and just makes the sender chat "Hello Server!".
107
103
108
-
### 3) Registering the command
104
+
### 3) Register the command
109
105
```java
110
106
publicfinalclassMyPluginextendsJavaPlugin {
111
107
@Override
@@ -124,3 +120,11 @@ This just registers the command, so it appears when we type `/myrootcommand`
0 commit comments