Skip to content

Commit a2824a3

Browse files
committed
Add Installation instructions
1 parent 1c1aaad commit a2824a3

File tree

4 files changed

+81
-6
lines changed

4 files changed

+81
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
*.iml
44
out
55
gen
6+
/target/

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,52 @@ public class MyPlugin extends JavaPlugin {
216216

217217
---
218218

219+
## Maven / Gradle Installation
220+
221+
To include Command Framework to the project, add the following repository and dependency to your build configuration. Replace `${version}` with the desired version tag.
222+
223+
### Maven
224+
225+
Add the repository and dependency to your `pom.xml`:
226+
227+
```xml
228+
<repositories>
229+
<repository>
230+
<id>croabeast-repo</id>
231+
<url>https://croabeast.github.io/repo/</url>
232+
</repository>
233+
</repositories>
234+
235+
<dependencies>
236+
<dependency>
237+
<groupId>me.croabeast</groupId>
238+
<artifactId>CommandFramework</artifactId>
239+
<version>${version}</version>
240+
<scope>compile</scope>
241+
</dependency>
242+
</dependencies>
243+
```
244+
245+
### Gradle
246+
247+
Add the repository and dependency to your `build.gradle`:
248+
249+
```groovy
250+
repositories {
251+
maven {
252+
url "https://croabeast.github.io/repo/"
253+
}
254+
}
255+
256+
dependencies {
257+
implementation "me.croabeast:CommandFramework:${version}"
258+
}
259+
```
260+
261+
Replace `${version}` with the appropriate module version.
262+
263+
---
264+
219265
## Conclusion
220266

221267
**Command Framework** (the collection of classes in the `me.croabeast.command` package) is designed to streamline command development for Minecraft plugins, particularly on Paper forks where runtime registration can be challenging. Its modular design, support for sub-commands, dynamic tab completion, and robust permission checks make it an ideal choice for modern plugin development.

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,14 @@
113113
<dependency>
114114
<groupId>org.jetbrains</groupId>
115115
<artifactId>annotations</artifactId>
116-
<version>24.0.1</version>
116+
<version>26.0.1</version>
117117
<scope>provided</scope>
118118
</dependency>
119119

120120
<dependency>
121121
<groupId>org.projectlombok</groupId>
122122
<artifactId>lombok</artifactId>
123-
<version>1.18.26</version>
123+
<version>1.18.36</version>
124124
<scope>provided</scope>
125125
</dependency>
126126

src/main/java/me/croabeast/command/SubCommand.java

Lines changed: 32 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,50 @@ public class SubCommand implements BaseCommand {
7878
* </p>
7979
*
8080
* @param parent the parent command (must not be {@code null}).
81-
* @param aliases the sub-command name, optionally including aliases separated by a semicolon.
81+
* @param name the sub-command name.
82+
* @param aliases the optional aliases.
8283
* @throws NullPointerException if the parent is {@code null} or if the name is blank.
8384
*/
8485
public SubCommand(Command parent, String name, String... aliases) {
8586
this.parent = Objects.requireNonNull(parent, "Parent cannot be null");
8687

8788
if (StringUtils.isBlank(name))
8889
throw new NullPointerException("Name is empty");
89-
90-
// Split the provided name string by semicolons to extract primary name and aliases.
91-
List<String> list = Arrays.asList(aliases);
90+
9291
this.name = name;
9392
this.permission = parent.getPermission() + '.' + this.name;
93+
94+
List<String> list = Arrays.asList(aliases);
9495
this.aliases.addAll(list);
9596
}
9697

98+
/**
99+
* Constructs a new {@code SubCommand} for the specified parent command and name.
100+
* <p>
101+
* The {@code name} parameter can include aliases separated by a semicolon.
102+
* The first element is taken as the primary name, and the subsequent elements are added as aliases.
103+
* The permission node is automatically set as the parent command's wildcard permission
104+
* concatenated with the sub-command's primary name.
105+
* </p>
106+
*
107+
* @param parent the parent command (must not be {@code null}).
108+
* @param name the sub-command name, optionally including aliases separated by a semicolon.
109+
* @throws NullPointerException if the parent is {@code null} or if the name is blank.
110+
*/
111+
public SubCommand(Command parent, String name) {
112+
this.parent = Objects.requireNonNull(parent, "Parent cannot be null");
113+
114+
if (StringUtils.isBlank(name))
115+
throw new NullPointerException("Name is empty");
116+
117+
List<String> list = new ArrayList<>(Arrays.asList(name.split(";")));
118+
this.name = list.get(0);
119+
this.permission = parent.getPermission() + '.' + this.name;
120+
if (list.size() == 1) return;
121+
122+
for (int i = 1; i < list.size(); i++) aliases.add(list.get(i));
123+
}
124+
97125
/**
98126
* Checks if the given {@link CommandSender} is permitted to execute this sub-command.
99127
* <p>

0 commit comments

Comments
 (0)