Introdution
Have you ever face difficulty of creating even simple spigot command working well? Are you a begginer and you got lost creating a command with more then one argument?
A The library offers easy and elegant approach of creating commands.
Spigot/Paper library dedicated for simplifying commands registration for your plugin!
See the documentation to see more advanced examples!
Join the support discord and visit the #programming channel for questions, contributions and ideas. Feel free to make pull requests with missing/new features, fixes, etc
Patterns
/hello <name:Text> <count:Number> <job:Text[Miner, Fisherman, Farmer]>
public final class Example extends JavaPlugin {
@Override
public void onEnable() {
CommandsApi commandsApi = CommandsFramework.enable(this);
commands.create("/hello <name:Text> <age:number> <job:Text[Miner, Fisherman, Farmer]>")
.onPlayerExecute(event ->
{
event.sender().sendMessage("You called the hello command");
var name = event.getString("name");
var age = event.getNumber("age");
var job = event.getString("job");
event.sender().sendMessage("Name: " + name + " Age: " + age + " Job: " + job);
}).register();
}
}
Templates
Is the most streight-forward way of creating command! Just add annotation @FCommand above a method and that's it!
public final class MyHelloCommand
{
@FCommand(pattern = "/hello <name:Text> <age:Number> <job:[Miner,Fisherman,Farmer]")
public void helloCommand(CommandSender sender, String name, int age, String job)
{
event.sender().sendMessage("Name: " + name + " Age: " + age + " Job: " + job);
}
}
public final class ExamplePlugin extends JavaPlugin {
@Override
public void onEnable() {
MyHelloCommand helloCommand = new MyHelloCommand();
Commands commands = CommandsFramework.enable(this);
commands.create(helloCommand).register();
}
}
Getting started
1. Install dependency
<dependency>
<groupId>io.github.jwdeveloper.spigot.commands</groupId>
<artifactId>commands-framework-core</artifactId>
<version>1.0.1</version>
</dependency>
2 . Create your first command
public final class Example extends JavaPlugin {
@Override
public void onEnable() {
CommandsApi commandsApi = CommandsFramework.enable(this);
commands.create("/hello <name:Text> <age:number> <job:Text[Miner, Fisherman, Farmer]>")
.onPlayerExecute(event ->
{
event.sender().sendMessage("You called the hello command");
var name = event.getString("name");
var age = event.getNumber("age");
var job = event.getString("job");
event.sender().sendMessage("Name: " + name + " Age: " + age + " Job: " + job);
}).register();
}
}
3. Use a command in the game
Contributing
Library documentation for contributors
Your improvements are welcome! Feel free to open an issue or pull request.
Similar projects
Plugin →Let Me Despawn
Improves performance by tweaking mob despawn rules. Say bye to pesky unintentional persistent mobs.
25MSueta
JourneyMap
Real-time map used for mapping in-game or your browser as you explore.
14.7MSueta
Emotecraft
Create your own emotes in Minecraft.
7.5MSueta
Simple Tpa
A simple tpa plugin which sends requests
5.4MSueta
Common Network
Forge and Fabric Unified Networking Solution
3.9MSueta
Set Home
A lightweight plugin for players to set their homes.
3.8MSueta