Skip to content

BraydenMotion/Shard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Shard

A command API for Spigot/Bukkit for 1.14

Table of Contents

Overview

Shard was created because, as I was making a lot of commands, I realized how tedious it is to make subcommands. Shard supports not only subcommands, but more vanilla style commands with no subcommands. This library was highly based on Lucko's command API for LuckPerms.

Features

  • Simple subcommand structure
  • New tab completion API
  • Vanilla style commands for simple command uses

Usage

Shard is not currently deployed anywhere, so you must install it manually:

mvn clean install

Once installed, you can add it to your project:

<dependencies>
    <dependency>
        <groupId>adiitya.spigot</groupId>
        <artifactId>shard</artifactId>
        <version>@VERSION@</version>
    </dependency>
</dependencies>

Examples

Creating a simple command:

import adiitya.shard.SingleCommand;
import adiitya.shard.completion.TabCompleter;
import java.util.List;
import org.bukkit.command.CommandSender;

public class ExampleCommand extends SingleCommand {
    
    public ExampleCommand(JavaPlugin plugin) {
        super(plugin, "example", "[page]");
    }

    @Override
    public void execute(CommandSender sender, List<String> args) {
        
        int page = args.isEmpty() ? 0 : Integer.parseInt(args.get(0));

        // more logic here
    }

    @Override
    public List<String> tabComplete(CommandSender sender, List<String> args) {
        return TabCompleter.empty();
    }   
}

Using the tab completion API:

    @Override
    public List<String> tabComplete(CommandSender sender, List<String> args) {
        return new TabCompleter()
            .add(0, new TabCompletion("yes", test -> "yes".startsWith(test)))
            .add(0, new TabCompletion("no", test -> "no".startsWith(test)))
            .get(args); // this will parse the args and return a list of valid completions
    }

About

A command API for Spigot/Bukkit 1.14

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages