package net.minecraftforge.event; import net.minecraftforge.fml.common.eventhandler.Cancelable; import net.minecraftforge.fml.common.eventhandler.Event; import net.minecraft.command.ICommand; import net.minecraft.command.ICommandSender; /** * CommandEvent is fired whenever a command is scheduled to be executed. * This event is fired during the invocation of CommandHandler#executeCommand(ICommandSender, String) * and ClientCommandHandler#executeCommand(ICommandSender, String).
*
* {@link #command} contains the instance of ICommand which is representative of the currently executing command.
* {@link #sender} contains the instance of ICommandSender for the given command sender.
* {@link #parameters} contains the arguments passed for the command execution.
* {@link #exception} begins null, but can be populated with an exception to be thrown within the command.
*
* This event is {@link Cancelable}.
* If the event is canceled, the execution of the command does not occur.
*
* This event does not have a result. {@link HasResult}
*
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.
**/ @Cancelable public class CommandEvent extends Event { private final ICommand command; private final ICommandSender sender; private String[] parameters; private Throwable exception; public CommandEvent(ICommand command, ICommandSender sender, String[] parameters) { this.command = command; this.sender = sender; this.setParameters(parameters); } public ICommand getCommand() { return command; } public ICommandSender getSender() { return sender; } public String[] getParameters() { return parameters; } public void setParameters(String[] parameters) { this.parameters = parameters; } public Throwable getException() { return exception; } public void setException(Throwable exception) { this.exception = exception; } }