Command Framework [1.7 - 1.21.4] icon

Command Framework [1.7 - 1.21.4] -----

A lightweight annotation based command system



Discord: https://discord.gg/uXVU8jmtpU

Command Framework


This framework is very lightweight annotation based command system that works similar to Bukkit's event system. It removes the necessity to add command to your plugin.yml but will still allow you to set command usage, description, permission, aliases, sender type, cooldown, minimum and maximum argument length through the code and adds bunch of new methods to improve your code.

Documentation

More information can be found on the wiki page. The Java documentations can be browsed. Questions related to the usage of Command Framework should be posted on the Github repo.

Donations

You like the framework? Then donate back me to support the development. Donations are more like motivation than money and, they are speeding up the development.

Using Command Framework

The project isn't in the Central Repository yet, so specifying a repository is needed.
To add this project as a dependency to your project, add the following to your pom.xml:

Maven dependency
Code (XML):
<repository>
    <id>jitpack.io </id>
    <url>https://jitpack.io </url>
</repository>
Code (XML):
<dependency>
    <groupId>com.github.Despical </groupId>
    <artifactId>CommandFramework </artifactId>
    <version>1.5.13 </version>
</dependency>

Gradle dependency

Code (XML):
repositories {
   maven { url 'https://jitpack.io' }
}
Code (XML):
dependencies {
   implementation 'com.github.Despical:CommandFramework:1.5.13';
}

Example usage

Code (Java):
import me.despical.commandframework.* ;
import me.despical.commandframework.annotations.* ;
import org.bukkit.Bukkit ;
import org.bukkit.plugin.java.JavaPlugin ;

import java.util.Arrays ;
import java.util.List ;
import java.util.concurrent.TimeUnit ;

public class ExampleClass extends JavaPlugin {

   @Override
    public void onEnable ( ) {
        // Initialize the framework before using
        // Don't forget to shade framework in to your project
       CommandFramework commandFramework = new CommandFramework ( this ) ;
        // Adding custom parameters without @Param and @Default annotations.
        // Now all String type objects will return first argument.
       commandFramework. addCustomParameter ( "String", arguments -> arguments. getArgument ( 0 ) ) ;
        // Adding custom parameters to use with @Param and optionally with @Default annotations.
       commandFramework. addCustomParameter ( "secondAsInt", arguments -> arguments. getLength ( ) > 1 ? arguments. getArgumentAsInt ( 1 ) : null ) ;
        // Then this will register all the @Command methods as a command
        // so there is no necessity to add command to your plugin.yml
       commandFramework. registerCommands ( this ) ;
    }

    // Before creating command the method must only have
    // CommandArguments parameter and also @Command annotation
   @Command (
       name = "example",
       fallbackPrefix = "prefix",
       aliases = { "firstAlias", "secondAlias" },
       permission = "example.permission",
       desc = "Sends an example message to sender",
       usage = "/example",
       min = 1,
       max = 5,
       onlyOp = false, // this option will ignore permission if it is set
        // be careful if you are using non-thread safe operations
        // and if you want to enable option below
       async = false,
       senderType = Command. SenderType. CONSOLE
    )
   @Cooldown (
       value = 10,
       timeUnit = TimeUnit. SECONDS,
       bypassPerm = "command.cooldownBypass",
       overrideConsole = true // console will now be affected by cooldown
    )
    public void exampleCommand (CommandArguments arguments ) {
        // CommandArguments class contains basic things related Bukkit commands
        // And here it's all done, you've created command with properties above!
       arguments. sendMessage ( "This is how you can create a example command using framework." ) ;
    }

   @Command (
       name = "noParams"
    )
    public void commandWithoutParameters ( ) {
       Bukkit. getConsoleSender ( ). sendMessage ( "This command is running without any parameters." ) ;
    }

   @Command (
       name = "customParamWithoutAnnotations",
       min = 1
    )
    // See CommandFramework#addCustomParameter method above.
    public void customParamCommand ( String firstParameter, CommandArguments arguments ) {
        // CommandArguments parameter can be added to anywhere in method as a parameter.
       arguments. sendMessage ( "First parameter is " + firstParameter ) ;
    }

   @Command (
       name = "customParams",
       min = 1
    )
    // If command is executed with only one argument then the default value will be accepted.
    // Otherwise, the given argument will be converted to specified type, in this case an int.
    // If parameter is not annotated by @Default then command will throw an exception on execution.
    // See the wiki page for creating custom parameters using @Param and @Default annotations.
    public void customParamsCommand (CommandArguments arguments,
                                   @Param ( "secondAsInt" )
                                   @ Default ( "50" )
                                    int secondArg ) {
       arguments. sendMessage ( "Second argument as integer is " + secondArg ) ;
    }

   @Command (
       name = "confirmationTest"
    )
   @Confirmation (
       message = "Are you sure, if so, please execute command again to confirm.",
       expireAfter = 10,
       bypassPerm = "confirmation.bypass",
       timeUnit = TimeUnit. SECONDS,
       overrideConsole = true
    )
    public void confirmationCommand (CommandArguments arguments ) {
       arguments. sendMessage ( "Confirmation successful." ) ;
    }

   @Flag (
       value = "test",
       prefix = "--"
    )
   @Command (
       name = "flag"
    )
    public void flagTest (CommandArguments arguments ) {
       arguments. sendMessage ( "Flag Present: " + arguments. isFlagPresent ( "test" ) ) ;
    }

   @ Option (
       value = "players",
       prefix = "--"
    )
   @Command (
       name = "option"
    )
    public void optionTest (CommandArguments arguments ) {
       arguments. sendMessage ( "Parsed Options: " + String. join ( ", ", arguments. getOption ( "players" ) ) ) ;
    }

    // Aliases don't need to be same with the command above
   @Completer (
       name = "example",
       aliases = { "firstAlias", "secondAlias" }
    )
    public List <String > exampleCommandCompletion ( /*CommandArguments arguments*/ /*no need to use in this case which is also supported*/ ) {
        return Arrays. asList ( "first", "second", "third" ) ;
    }
}
Example plugins
You can always DM me if you are using this framework and want to be on list.

Additional links
Copyright 2025 © Berke Akçen
Resource Information
Author:
----------
Total Downloads: 5,840
First Release: Mar 10, 2021
Last Update: Jan 3, 2025
Category: ---------------
All-Time Rating:
2 ratings
Find more info at github.com...
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings