Skip to content

ar1hurgit/command-framework

Repository files navigation

Command Framework

Framework de commandes moderne pour plugins Minecraft Paper et Spigot, construit avec Gradle et Java 21.

JitPack GitHub Paper Spigot Java Gradle

Commits Issues Last Commit Repo Size

Contributors Stars

Overview

Command Framework permet de créer des commandes Paper/Spigot avec une API orientée annotations, un parsing automatique des arguments, la validation, la tab-completion, l'aide générée automatiquement et des points d'extension propres pour les parsers, completions et middlewares.

Le projet cible actuellement :

  • Java 21
  • Paper 1.21 / 1.21.1
  • Spigot 1.21 / 1.21.1
  • Gradle

Features

  • Déclaration de commandes via annotations : @Command, @Alias, @Permission, @Description, @Usage, @Cooldown
  • Exécution et validation avec @Execute, @Optional, @Range, @Suggest
  • Parsing automatique pour String, int, double, boolean, Player, OfflinePlayer, UUID et Enum
  • Registry dynamique avec register(...) et scan de package
  • Tab-completion intelligente pour joueurs, enums, suggestions annotées et sous-commandes
  • Help automatique avec /command help
  • Middlewares, métriques et extensions custom

Compatibility

Platform Minecraft Java Status
Paper 1.21 / 1.21.1 21 Supported
Spigot 1.21 / 1.21.1 21 Supported

Installation

Gradle

Ajoute JitPack dans ton settings.gradle :

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        mavenCentral()
        maven { url 'https://jitpack.io' }
    }
}

Puis ajoute la dépendance dans ton build.gradle :

dependencies {
    implementation 'com.github.ar1hurgit:command-framework:v1.0.0-alpha'
}

Maven

Ajoute JitPack dans ton pom.xml :

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

Puis ajoute la dépendance :

<dependency>
    <groupId>com.github.ar1hurgit</groupId>
    <artifactId>command-framework</artifactId>
    <version>v1.0.0-alpha</version>
</dependency>

Quick Start

Exemple d'utilisation simple :

import me.ar1hurgit.commandframework.framework.annotation.Command;
import me.ar1hurgit.commandframework.framework.annotation.Description;
import me.ar1hurgit.commandframework.framework.annotation.Execute;
import me.ar1hurgit.commandframework.framework.annotation.Permission;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

@Command("ban")
@Permission("staff.ban")
@Description("Ban un joueur")
public final class BanCommand {

    @Execute
    public void execute(CommandSender sender, Player target, String reason) {
        sender.sendMessage("Banned " + target.getName() + " for " + reason);
    }
}

Dans ton plugin :

import me.ar1hurgit.commandframework.framework.core.CommandFramework;
import org.bukkit.plugin.java.JavaPlugin;

public final class MyPlugin extends JavaPlugin {

    private CommandFramework commandFramework;

    @Override
    public void onEnable() {
        commandFramework = CommandFramework.builder(this).build();
        commandFramework.register(new BanCommand());
    }
}

API Highlights

Le framework est organisé en modules clairs :

  • framework.annotation : annotations publiques du framework
  • framework.core : configuration, métadonnées, métriques
  • framework.registry : enregistrement, scan et routing
  • framework.executor : pipeline d'exécution
  • framework.parser : parsers d'arguments
  • framework.completion : tab-completion extensible
  • framework.validation : permission, cooldown, sender, ranges
  • framework.help : génération automatique de l'aide
  • framework.context : contexte d'exécution
  • framework.exception : exceptions typées
  • framework.util : utilitaires internes

Extension

Parser custom :

commandFramework.registerParser(MyType.class, context -> new MyType(context.input()));

Completion custom :

commandFramework.registerCompletion(
    MyType.class,
    (context, parameter, input) -> List.of("alpha", "beta", "gamma")
);

Middleware :

commandFramework.addMiddleware(new CommandMiddleware() {
    @Override
    public void beforeExecute(CommandContext context) {
        context.sender().sendMessage("Running " + context.definition().commandKey());
    }
});

Scan de package :

commandFramework.scanAndRegister("me.example.myplugin.command");

Development

Pour compiler le projet localement :

.\gradlew.bat build

Support

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages