https://github.com/jwdeveloper/commandsframework
https://github.com/jwdeveloper/commandsframework
Last synced: 16 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jwdeveloper/commandsframework
- Owner: jwdeveloper
- Created: 2024-09-08T13:34:01.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-09-12T13:43:23.000Z (over 1 year ago)
- Last Synced: 2025-01-31T17:13:58.543Z (about 1 year ago)
- Language: Java
- Size: 155 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: docs/README.md
Awesome Lists containing this project
README
#### 1. Install the dependencies
> Make sure you are installing the latest version!
#### [Check out the current version](https://central.sonatype.com/artifact/io.github.jwdeveloper.spigot.commands/CommandsFramework)
```xml
io.github.jwdeveloper.spigot.commands
commands-framework-core
1.0.8
compile
```
How to fix this error?
java.lang.NoClassDefFoundError: io/github/jwdeveloper/spigot/commands/CommandsFramework
This is the common error while using the maven dependencies to your plugin.
The error means that the dependency classes `has not been included` in the output jar file.
#### Fix it by using the `Maven Shade Plugin`
> Maven shade plugin is a "script" that runs during the compilation time and copy all the dependencies
> classes into the output jar
Copy this into the `pom.xml`
```xml
org.apache.maven.plugins
maven-shade-plugin
3.5.3
package
shade
```
After do it, reload the `pom.xml` and compile the project with maven `install` action
The output jar should be into the folder `/yourproject/target`
____
#### 2. Create a command
There are three different ways of registering commands
- [Builder](#builder) - default way of creating commands it has the most features
- [Pattern](#pattern) - simpler way of creating command, create them as string `/hello `
- [Annotations](#annotations) - the simplest way, it uses `Annotations` over methods to register new command
## Builder
`Builder` - The essential approach of a command registration.
A command is created by using chained fluent builder.
It gives you access to all the properties and features.
> The name `builder` comes from the design pattern [Builder](https://refactoring.guru/design-patterns/builder)
[filename](code/basic-builder.md ':include')
## Pattern
`Pattern` - The pattern is higher abstraction. It parses string
pattern into a builder, that can be later adjusted.
[filename](code/basic-pattern.md ':include')
## Annotations
`Annotations` - The highest abstraction, very simple to use. By using the `@FCommand` over
methods or class you can simply create new command
[filename](code/basic-annotations.md ':include')