Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Wairovel Command API

A minimal event-driven command core for Minecraft servers.

Build & Test Java 16+ Paper 1.16.5+

🌐 Русский


The Problem

The standard Bukkit/Paper API does not provide a convenient way for other plugins to know:

  • Was the command executed successfully?
  • Did an error occur?
  • Did the player lack permission?
  • Was the command cancelled?

Wairovel Command API solves this by providing a unified event-driven API for registering commands with automatic execution result event publishing.


How It Works

Wairovel Command API is installed as a standalone plugin on the server (similar to Vault, PlaceholderAPI, or ProtocolLib). Other plugins connect to it through a shared API.

server/plugins/
β”œβ”€β”€ Wairovel-Command-API-0.1.0.jar   ← install once on the server
β”œβ”€β”€ YourSpawnPlugin.jar               ← uses the API
└── YourRewardsPlugin.jar             ← listens to command events

This is necessary because the library's main purpose is inter-plugin communication β€” all plugins must share a single EventBus to see each other's command results.


Installation

1. Install the plugin

Download Wairovel-Command-API-0.1.0.jar and place it in your server's plugins/ folder.

2. Add API dependency to your plugin

Gradle (Kotlin DSL)

repositories {
    maven("https://jitpack.io")
}

dependencies {
    compileOnly("com.github.Wairovel.Wairovel-Command-API:api:0.1.0")
}

Maven

<dependency>
    <groupId>com.github.Wairovel.Wairovel-Command-API</groupId>
    <artifactId>api</artifactId>
    <version>0.1.0</version>
    <scope>provided</scope>
</dependency>

3. Add dependency in plugin.yml

depend: [Wairovel-Command-API]

Quick Start

Plugin A β€” Register a command

public class SpawnPlugin extends JavaPlugin {

    @Override
    public void onEnable() {
        CommandManager manager = WairovelCommandApi.instance().commands();

        WairovelCommand spawn = manager.register("spawn");
        spawn.permission("server.spawn")
             .description("Teleport to spawn")
             .executor(context -> {
                 Player player = context.sender(Player.class);
                 player.teleport(player.getWorld().getSpawnLocation());
                 player.sendMessage("Teleported to spawn!");
                 context.success();
             });
    }
}

Plugin B β€” Event listener (a different plugin!)

public class RewardsPlugin extends JavaPlugin {

    @Override
    public void onEnable() {
        CommandManager manager = WairovelCommandApi.instance().commands();

        manager.subscribe(CommandExecutedEvent.class, event -> {
            if (event.command().equals("spawn") && event.isSuccess()) {
                Player player = event.sender(Player.class);
                giveReward(player);
                player.sendMessage("You received a reward for teleporting!");
            }
        });
    }
}

Plugin C β€” Audit logging

public class AuditPlugin extends JavaPlugin {

    @Override
    public void onEnable() {
        CommandManager manager = WairovelCommandApi.instance().commands();

        manager.subscribe(CommandExecutedEvent.class, event -> {
            getLogger().info(String.format(
                "[%s] /%s %s -> %s (%dms)",
                event.sender(Player.class).getName(),
                event.command(),
                String.join(" ", event.args()),
                event.result().name(),
                event.duration()
            ));
        });
    }
}

API Reference

CommandResult

Value Description
SUCCESS Command executed successfully
NO_PERMISSION Sender lacks required permission
INVALID_ARGUMENT Invalid argument provided
NOT_FOUND Resource not found (home, warp, etc.)
CANCELLED Command was cancelled
ERROR Unexpected error occurred

CommandContext

context.sender();           // Object β€” raw sender
context.sender(Player.class); // Typed cast
context.command();          // Command name
context.args();             // String[] arguments
context.arg(0);             // Specific argument (null-safe)

context.success();          // Mark as success
context.fail();             // Mark as failed
context.noPermission();     // No permission
context.invalidArgument();  // Invalid argument
context.notFound();         // Resource not found
context.cancel();           // Cancelled
context.error(exception);   // Error with throwable

WairovelCommand

WairovelCommand cmd = manager.register("home");
cmd.permission("homes.use");
cmd.description("Teleport home");
cmd.executor(ctx -> { ... });
cmd.enabled(false);         // Temporarily disable
cmd.enabled(true);          // Re-enable
cmd.unregister();           // Full unregistration

CommandExecutedEvent

event.command();            // Command name
event.sender();             // Sender
event.sender(Player.class); // Typed sender
event.args();               // Arguments
event.result();             // CommandResult
event.isSuccess();          // Quick success check
event.duration();           // Execution time (ms)
event.timestamp();          // Event time (epoch ms)
event.error();              // Throwable if ERROR

Architecture

wairovel-command-api/
β”œβ”€β”€ api/        # Public API β€” zero platform dependencies
β”œβ”€β”€ core/       # Internal implementation
└── paper/      # Paper-specific integration
  • api β€” dependency for all consumer plugins
  • core β€” internal logic (not for external use)
  • paper β€” bridge to Paper with automatic version detection:
    • 1.16.5–1.20.4 β€” Bukkit CommandMap (legacy)
    • 1.20.6+ β€” Paper LifecycleEvents + Brigadier (modern)

Supported Versions

Platform Versions Java
Paper 1.16.5 – 1.21.x Java 16+

Roadmap (v0.2+)

  • Command arguments API
  • Tab completion
  • Permission handlers / middleware
  • Brigadier deep integration
  • Async execution support
  • Command cooldowns
  • Command analytics
  • Velocity / Minestom platforms

Requirements

  • Java 16+
  • Paper 1.16.5+
  • Gradle

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages