@@ -95,7 +95,6 @@ Create a custom command by extending `BukkitCommand`:
9595package com.example.myplugin.command ;
9696
9797import me.croabeast.command.BukkitCommand ;
98- import me.croabeast.command.BaseCommand ;
9998import me.croabeast.command.SubCommand ;
10099import me.croabeast.command.TabBuilder ;
101100import me.croabeast.command.DefaultPermissible ;
@@ -105,54 +104,54 @@ import org.jetbrains.annotations.NotNull;
105104
106105public class GreetCommand extends BukkitCommand implements DefaultPermissible {
107106
108- /**
109- * Constructs the GreetCommand with a reference to the owning plugin.
110- *
111- * @param plugin the plugin instance.
112- */
113- public GreetCommand (Plugin plugin ) {
114- super (plugin, " greet" );
115-
116- // Set up the main command executable
117- setExecutable((CommandSender sender, String [] args) - > {
118- sender. sendMessage(" Hello, " + sender. getName() + " !" );
119- return Executable . State . TRUE ;
120- });
121-
122- // Register a sub-command "reload" with an alias "r"
123- SubCommand reloadSub = new SubCommand (this , " reload;r" );
124- reloadSub. setPredicate((sender, args) - > {
125- // Reload logic here
126- sender. sendMessage(" GreetCommand configuration reloaded." );
127- return true ;
128- });
129- registerSubCommand(reloadSub);
130- }
131-
132- /**
133- * Provides custom tab completion for the command.
134- *
135- * @param sender the command sender.
136- * @param alias the command alias used.
137- * @param args the arguments passed to the command.
138- * @return a list of suggestions.
139- */
140- @NotNull
141- @Override
142- public java.util.List<String > tabComplete (@NotNull CommandSender sender , @NotNull String alias , String [] args ) {
143- // Create a simple TabBuilder for suggestions
144- TabBuilder builder = new TabBuilder ();
145- if (args. length == 1 ) {
146- // Suggest "hello" and "hi" when no sub-command is specified
147- builder. addArgument(1 , " hello" );
148- builder. addArgument(1 , " hi" );
149- } else if (args. length > 1 ) {
150- // Optionally, provide additional suggestions for further arguments
151- builder. addArgument(args. length, " option1" );
152- builder. addArgument(args. length, " option2" );
153- }
154- return builder. build(sender, args);
107+ /**
108+ * Constructs the GreetCommand with a reference to the owning plugin.
109+ *
110+ * @param plugin the plugin instance.
111+ */
112+ public GreetCommand (Plugin plugin ) {
113+ super (plugin, " greet" );
114+
115+ // Set up the main command executable
116+ setPredicate((CommandSender sender, String [] args) - > {
117+ sender. sendMessage(" Hello, " + sender. getName() + " !" );
118+ return Executable . State . TRUE ;
119+ });
120+
121+ // Register a sub-command "reload" with an alias "r"
122+ SubCommand reloadSub = new SubCommand (this , " reload;r" );
123+ reloadSub. setPredicate((sender, args) - > {
124+ // Reload logic here
125+ sender. sendMessage(" GreetCommand configuration reloaded." );
126+ return true ;
127+ });
128+ registerSubCommand(reloadSub);
129+ }
130+
131+ /**
132+ * Provides custom tab completion for the command.
133+ *
134+ * @param sender the command sender.
135+ * @param alias the command alias used.
136+ * @param args the arguments passed to the command.
137+ * @return a list of suggestions.
138+ */
139+ @NotNull
140+ @Override
141+ public java.util.List<String > tabComplete (@NotNull CommandSender sender , @NotNull String alias , String [] args ) {
142+ // Create a simple TabBuilder for suggestions
143+ TabBuilder builder = new TabBuilder ();
144+ if (args. length == 1 ) {
145+ // Suggest "hello" and "hi" when no sub-command is specified
146+ builder. addArgument(1 , " hello" );
147+ builder. addArgument(1 , " hi" );
148+ } else if (args. length > 1 ) {
149+ // Optionally, provide additional suggestions for further arguments
150+ builder. addArgument(args. length, " option1" );
151+ builder. addArgument(args. length, " option2" );
155152 }
153+ return builder. build(sender, args);
154+ }
156155}
157156```
158157
0 commit comments