Initialisation complète de la bibliothèque betterMcCommands (DSL, arguments typés, cycle de vie des événements, injection dynamique CommandMap)
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
package fr.luc.bettermccommands.demo;
|
||||
|
||||
import fr.luc.bettermccommands.BetterMcCommands;
|
||||
import fr.luc.bettermccommands.demo.commands.DemoBaseCommand;
|
||||
import fr.luc.bettermccommands.demo.commands.DemoListener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
/**
|
||||
* Exemple de plugin Bukkit/Paper intégrant la bibliothèque betterMcCommands.
|
||||
*/
|
||||
public class DemoPlugin extends JavaPlugin {
|
||||
|
||||
private BetterMcCommands commandsManager;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getLogger().info("Initialisation de betterMcCommands Demo...");
|
||||
|
||||
// 1. Initialisation du gestionnaire pour ce plugin
|
||||
this.commandsManager = BetterMcCommands.create(this);
|
||||
|
||||
// 2. Enregistrement des écouteurs d'événements de commandes
|
||||
this.commandsManager.registerListeners(new DemoListener());
|
||||
|
||||
// 3. Enregistrement de la commande de démonstration /commande-demo
|
||||
DemoBaseCommand.create().register();
|
||||
|
||||
getLogger().info("betterMcCommands Demo activé avec succès !");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
getLogger().info("Désactivation de betterMcCommands Demo...");
|
||||
|
||||
// Nettoyage et désenregistrement à chaud de toutes les commandes
|
||||
if (commandsManager != null) {
|
||||
commandsManager.unregisterAll();
|
||||
}
|
||||
|
||||
getLogger().info("betterMcCommands Demo désactivé.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user