Skip to content
This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
/ Zetsu Public archive

Annotation-based Command API for Spigot.

Notifications You must be signed in to change notification settings

KermanIsPretty/Zetsu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Zetsu

Extensive Command API for the Spigot API

Installation

  1. Retrieve the jar in /target/ or compile the plugin via git and maven.
  2. Add the project as a maven dependency or put it in your build path.
  3. Start using the API!

You can also use maven:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependency>
    <groupId>me.blazingtide</groupId>
    <artifactId>Zetsu</artifactId>
    <version>1.2-SNAPSHOT</version>
    <scope>compile</scope>
</dependency>

Usage

import org.bukkit.plugin.java.JavaPlugin;

public class Plugin extends JavaPlugin {

    private Zetsu zetsu;

    @Override
    public void onEnable() {
        zetsu = new Zetsu(this);

        zetzu.registerParameterAdapter(Object.class, new ObjectTypeAdapter());
        zetsu.registerCommands(this);
    }

    @Command(labels = {"example"})
    public void execute(CommandSender sender, @Param("message") /* You do not need @Param, but is used for help messages or it uses the class name. */ String exampleString) {
        sender.sendMessage(exampleString);
    }

    @Command(labels = {"example subcommand"})
    @Permissible("permission.admin")
    //Player requires the permission node "permission.admin" to perform this command
    public void executeSubCommand(Player player) { //Player only command
        player.sendMessage("You're a player!");
    }

    @Command(labels = {"example completable"})
    public void execute(CommandSender sender, /* Allows for "Hey!" to be tab completable */ @Completable({"Hey!"}) String exampleString) {
        sender.sendMessage(exampleString);
    }

    @Command(labels = {"example object"})
    public void execute(CommandSender sender, Object example) { //Object paraam type
        sender.sendMessage(example);
    }

    //Register Custom Type Adapters
    public class ObjectTypeAdapter implements ParameterAdapter<Object> {

        @Override
        public Object process(String str) {
            return str;
        }

        @Override
        public void processException(CommandSender sender, String given, Exception exception) {
            sender.sendMessage(ChatColor.RED + "'" + given + "' is not a valid object.");
        }
    }
}

Contact

Telegram: @BlazingTide Discord: BlazingTide#0001

About

Annotation-based Command API for Spigot.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages