Skip to content

CraftsBlock/CraftsNet-CLI

Repository files navigation

CraftsNet-CLI

Simple CLI integration for craftsnet

Latest Release on Maven GitHub code size in bytes GitHub GitHub all releases GitHub issues


CraftsNet-CLI is used to add a simple-to-use command line interface to be used within craftsnet.

Installation

Maven

<repositories>
  ...
  <repository>
    <id>craftsblock-releases</id>
    <name>CraftsBlock Repositories</name>
    <url>https://repo.craftsblock.de/releases</url>
  </repository>
</repositories>
<dependencies>
  ...
  <dependency>
    <groupId>de.craftsblock.craftsnet.modules</groupId>
    <artifactId>cli</artifactId>
    <version>VERSION</version>
  </dependency>
</dependencies>

Gradle

repositories {
  ...
  maven { url "https://repo.craftsblock.de/releases" }
  mavenCentral()
}
dependencies {
  ...
  implementation "de.craftsblock.craftsnet.modules:cli:VERSION"
}

Quick Start

  1. Firstly you need to declare the CraftsNet-CLI addon as dependency to your addon / system. You can use the depends section in you addon.json or the @Depends annotation if you start inline. If you do not use addons at all you can create your craftsnet instance from this addon:
void main() {
    // Do not disable the addon system as you need to load CraftsNetCLI as an inline addon!
    CraftsNet.create(CraftsNetCLI.class)
            .build();
}
  1. You need to create a command executor which is responsible for dispatching you command.
import de.craftsblock.cnet.module.cli.annotation.CommandMeta;
import de.craftsblock.cnet.module.cli.command.Command;
import de.craftsblock.cnet.module.cli.command.CommandExecutor;
import de.craftsblock.craftsnet.autoregister.meta.AutoRegister;
import de.craftsblock.craftsnet.logging.Logger;
import org.jetbrains.annotations.NotNull;

@AutoRegister
@CommandMeta(name = "test", aliases = {"my", "command"})
public class MyCommand implements CommandExecutor {

    @Override
    public void onCommand(@NotNull Command command, String alias, @NotNull String[] args, @NotNull Logger logger) {
        logger.info("Hello, World!");
    }

}

You can use the auto register system of craftsnet to automatically register your command. If you want to auto register you command executor you need to add the @CommandMeta annotation to your command executor.

Each command must have a primary name which can not be used twice. Additionally, it can have multiple aliases which are alternative names for the command.

Open Source Licenses

We are using some third party open source libraries. Below you find a list of all third party open source libraries used:

Name Description Licecnse
CraftsNet Easy creation of HTTP routes and WebSocket endpoints in Java. Apache License 2.0
CraftsCore https://repo.craftsblock.de/#/releases/de/craftsblock/craftscore Apache License 2.0

Support and contribution

If you have any questions or have found a bug, please feel free to let us know in our issue tracker. We appreciate any help and welcome your contributions to improve the CraftsNet-CLI project.

About

Simple CLI integration for craftsnet

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages