66
77# ⚡ Command Framework
88
9- A modern, flexible command framework for Bukkit/Spigot and especially Paper Minecraft servers.
10- Easily create, register, and manage commands at runtime—even on Paper, where this is usually difficult.
9+ A modern, flexible command framework for Bukkit/Spigot and especially Paper Minecraft servers.<br >
1110Easily create, register, and manage commands at runtime—even on Paper, where this is usually difficult.
1211
1312---
@@ -20,19 +19,17 @@ Easily create, register, and manage commands at runtime—even on Paper, where t
2019- ✨ ** Tab Completion:** Context-aware suggestions with ` TabBuilder ` .
2120- 🔐 ** Permissions:** Wildcard and custom permission checks.
2221- 🧑💻 ** Fluent API:** Quickly build commands with ` CommandBuilder ` .
23- import me.croabeast.command.DefaultPermissible;
24- import org.bukkit.command.CommandSender;
25- import org.bukkit.plugin.Plugin;
26- ## 🛠️ Quick Example
2722
28- Create and register a simple command with a sub-command:
23+ ## 🛠️ Quick Example
2924
25+ Create and register a simple command with a sub-command:<br >
3026In your plugin’s main class (extending ` JavaPlugin ` ), register the command:
3127
3228``` java
3329package com.example.myplugin ;
3430
35- import com.example.myplugin.command.GreetCommand ;
31+ import me.croabeast.command.BukkitCommand ;
32+ import me.croabeast.command.SubCommand ;
3633import org.bukkit.plugin.java.JavaPlugin ;
3734
3835public class MyPlugin extends JavaPlugin {
@@ -42,10 +39,29 @@ public class MyPlugin extends JavaPlugin {
4239 // Create an instance of GreetCommand and register it
4340 GreetCommand greetCommand = new GreetCommand (this );
4441 greetCommand. register();
45-
42+
4643 // To unregister the command later, call:
4744 // greetCommand.unregister();
4845 }
46+
47+ // Define the GreetCommand class
48+ // It can be anywhere in your project
49+ static class GreetCommand extends BukkitCommand {
50+
51+ GreetCommand (JavaPlugin plugin ) {
52+ super (plugin, " greet" );
53+ setDescription(" Greet command" );
54+ setPermission(" my-plugin.greet" );
55+
56+ SubCommand sub = new SubCommand (plugin, " hello" );
57+ sub. setPermission(" my-plugin.greet.hello" );
58+ sub. setPredicate((sender, args) - > {
59+ sender. sendMessage(" Hello, " + sender. getName() + " !" );
60+ return true ;
61+ });
62+ addSubCommand(sub);
63+ }
64+ }
4965}
5066```
5167
@@ -107,7 +123,7 @@ Replace `${version}` with the latest version.
107123
108124## 🎉 Happy Coding!
109125
110- Build powerful, modern commands for your Minecraft plugin with ease!
126+ Build powerful, modern commands for your Minecraft plugin with ease!< br >
111127Questions? Join our [ Discord] ( https://discord.com/invite/gzzhVqgy3b ) 💬
112128
113129— * CroaBeast*
0 commit comments