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,54 @@
|
||||
package fr.luc.bettermccommands.event;
|
||||
|
||||
import fr.luc.bettermccommands.api.CommandContext;
|
||||
import fr.luc.bettermccommands.api.CommandNode;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
/**
|
||||
* Événement déclenché lorsqu'un joueur tente d'exécuter une commande soumise à un temps de recharge (Cooldown) actif.
|
||||
* <p>
|
||||
* Si l'événement est annulé ({@code setCancelled(true)}), l'exécution de la commande est autorisée exceptionnellement.
|
||||
*/
|
||||
public class CommandCooldownEvent extends CancellableCommandEvent {
|
||||
|
||||
private final Duration remainingCooldown;
|
||||
private String customMessage;
|
||||
|
||||
/**
|
||||
* Crée un événement de cooldown de commande.
|
||||
*
|
||||
* @param node Le nœud de commande.
|
||||
* @param sender L'émetteur sous cooldown.
|
||||
* @param context Le contexte de la commande.
|
||||
* @param remainingCooldown La durée restante avant expiration.
|
||||
*/
|
||||
public CommandCooldownEvent(CommandNode node, CommandSender sender, CommandContext context, Duration remainingCooldown) {
|
||||
super(node, sender, context);
|
||||
this.remainingCooldown = remainingCooldown;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return La durée restante avant la fin du cooldown.
|
||||
*/
|
||||
public Duration getRemainingCooldown() {
|
||||
return remainingCooldown;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Le message personnalisé éventuel, ou {@code null}.
|
||||
*/
|
||||
public String getCustomMessage() {
|
||||
return customMessage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Définit un message d'avertissement de cooldown sur-mesure.
|
||||
*
|
||||
* @param customMessage Le message au format MiniMessage ou couleurs Minecraft.
|
||||
*/
|
||||
public void setCustomMessage(String customMessage) {
|
||||
this.customMessage = customMessage;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user