Minestom/src/main/java/net/minestom/server/event/player/PlayerCommandEvent.java

51 lines
1.1 KiB
Java
Raw Normal View History

package net.minestom.server.event.player;
2020-04-05 10:15:21 +02:00
2020-04-24 03:25:58 +02:00
import net.minestom.server.entity.Player;
import net.minestom.server.event.CancellableEvent;
import net.minestom.server.event.PlayerEvent;
2020-10-24 16:33:13 +02:00
import org.jetbrains.annotations.NotNull;
2020-04-05 10:15:21 +02:00
2020-05-28 19:15:55 +02:00
/**
2020-10-15 21:16:31 +02:00
* Called every time a player send a message starting by '/'.
2020-05-28 19:15:55 +02:00
*/
public class PlayerCommandEvent extends PlayerEvent implements CancellableEvent {
2020-04-05 10:15:21 +02:00
private String command;
private boolean cancelled;
2020-10-24 16:33:13 +02:00
public PlayerCommandEvent(@NotNull Player player, @NotNull String command) {
super(player);
2020-04-05 10:15:21 +02:00
this.command = command;
}
2020-05-28 19:15:55 +02:00
/**
2020-10-15 21:16:31 +02:00
* Gets the command used (command name + arguments).
2020-07-24 16:11:48 +02:00
*
2020-05-28 19:15:55 +02:00
* @return the command that the player wants to execute
*/
2020-10-24 16:33:13 +02:00
@NotNull
2020-04-05 10:15:21 +02:00
public String getCommand() {
return command;
}
2020-05-28 19:15:55 +02:00
/**
2020-10-15 21:16:31 +02:00
* Changes the command to execute.
2020-05-28 19:15:55 +02:00
*
* @param command the new command
*/
2020-10-24 16:33:13 +02:00
public void setCommand(@NotNull String command) {
2020-04-05 10:15:21 +02:00
this.command = command;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
2020-04-05 10:15:21 +02:00
}