Skip to content

Commit 98b9dd8

Browse files
Merge pull request #1 from DatAsianBoi123/master
merge 2.0.0
2 parents 03f4a1e + 18eb0f6 commit 98b9dd8

Some content is hidden

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

51 files changed

+1975
-1121
lines changed

.idea/inspectionProfiles/Project_Default.xml

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/misc.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 DatAsianBoi123
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# CommandCore
22
CommandCore is a simple, yet powerful command framework for the Spigot API.
3-
43
## Installation
54
**Java 8 or higher is required**
65

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.
98
109
Clone this repository onto your local computer and run the command `mvn clean install` in that directory.
1110
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
4948

5049
## Usage
5150
### 1) Initialize CommandCore in your plugin
51+
5252
```java
53+
import com.datasiqn.commandcore.CommandCore;
54+
5355
public final class MyPlugin extends JavaPlugin {
54-
@Override
55-
public void onEnable() {
56-
// Init CommandCore
57-
CommandCore.init(this, "myrootcommand");
58-
// ...
59-
}
56+
@Override
57+
public void onEnable() {
58+
// Init CommandCore
59+
CommandCore.init(this, "myrootcommand");
60+
// ...
61+
}
6062
}
6163
```
6264
Using the static method `CommandCore.init(...)` initializes CommandCore. After doing this, you can access the instance from anywhere by using `CommandCore.getInstance()`
6365

64-
### 2) Creating a command
66+
### 2) Create a command
6567

6668
```java
67-
import com.datasiqn.commandcore.arguments.ArgumentType;
68-
import com.datasiqn.commandcore.commands.Command;
69-
import com.datasiqn.commandcore.commands.builder.*;
69+
import com.datasiqn.commandcore.argument.type.ArgumentType;
70+
import com.datasiqn.commandcore.command.builder.*;
7071

7172
public class GreetCommand {
72-
// Make sure to use the com.datasiqn.commandcore.commands.Command import!!
73-
private final Command command = new CommandBuilder<>()
74-
.description("Greets a player")
75-
.executes(context -> context.getSource().getSender().sendMessage("You ran this command with no arguments")) // Line 5
76-
.then(LiteralBuilder.literal("player")
77-
.then(ArgumentBuilder.argument(ArgumentType.PLAYER, "player")
78-
.requiresPlayer()
79-
.executes(context -> context.getSource().getPlayer().unwrap().chat("Hello " + context.getArguments().get(1, ArgumentType.PLAYER).unwrap().getName()))))
80-
.then(LiteralBuilder.literal("server")
81-
.requiresPlayer()
82-
.executes(context -> context.getSource().getPlayer().unwrap().chat("Hello Server!")))
83-
.build();
84-
85-
public Command getCommand() {
86-
return command;
73+
public CommandBuilder getCommand() {
74+
return new CommandBuilder()
75+
.description("Greets a player")
76+
.executes(context -> context.getSource().sendMessage("You ran this command with no arguments")) // Line 5
77+
.then(LiteralBuilder.literal("player")
78+
.then(ArgumentBuilder.argument(ArgumentType.PLAYER, "player")
79+
.requiresPlayer()
80+
.executes(context -> context.getSource().getPlayer().chat("Hello " + context.getArguments().get(1, ArgumentType.PLAYER).getName()))))
81+
.then(LiteralBuilder.literal("server")
82+
.requiresPlayer()
83+
.executes(context -> context.getSource().getPlayer().chat("Hello Server!")));
8784
}
8885
}
8986
```
9087
The `CommandBuilder` is what you use create commands.
9188

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-
9489
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.
9590

9691
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
10196

10297
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.
10398

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`).
105101

106102
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!".
107103

108-
### 3) Registering the command
104+
### 3) Register the command
109105
```java
110106
public final class MyPlugin extends JavaPlugin {
111107
@Override
@@ -124,3 +120,11 @@ This just registers the command, so it appears when we type `/myrootcommand`
124120
Now, lets see this baby in action!
125121

126122
<img src=https://user-images.githubusercontent.com/55264711/197649001-c165521c-7153-44bc-9827-7d7da41a9360.gif width=500px />
123+
124+
## Contributing
125+
You can contribute to this project by
126+
* Creating an [issue](https://github.com/DatAsianBoi123/CommandCore/issues/new)
127+
* [Forking](https://github.com/DatAsianBoi123/CommandCore/fork) this repo
128+
* Creating a [pull request](https://github.com/DatAsianBoi123/CommandCore/compare)
129+
---
130+
Have any questions? Ask me on [discord](https://discord.com)! My tag is `datasianboi123`

pom.xml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>com.datasiqn</groupId>
88
<artifactId>commandcore</artifactId>
9-
<version>2.0.0-SNAPSHOT</version>
9+
<version>2.0.0</version>
1010

1111
<properties>
1212
<maven.compiler.source>8</maven.compiler.source>
@@ -102,14 +102,21 @@
102102
<dependency>
103103
<groupId>com.github.DatAsianBoi123</groupId>
104104
<artifactId>ResultAPI</artifactId>
105-
<version>1.1.0</version>
105+
<version>99ce07576b</version>
106106
<scope>compile</scope>
107107
</dependency>
108108

109+
<dependency>
110+
<groupId>junit</groupId>
111+
<artifactId>junit</artifactId>
112+
<version>4.13.2</version>
113+
<scope>test</scope>
114+
</dependency>
115+
109116
<dependency>
110117
<groupId>org.jetbrains</groupId>
111118
<artifactId>annotations</artifactId>
112-
<version>23.0.0</version>
119+
<version>24.0.1</version>
113120
</dependency>
114121
</dependencies>
115122
</project>

0 commit comments

Comments
 (0)