2020-05-07 15:46:21 +02:00
|
|
|
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;
|
2020-05-07 15:46:21 +02:00
|
|
|
import net.minestom.server.event.CancellableEvent;
|
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
|
|
|
*/
|
2020-04-05 10:15:21 +02:00
|
|
|
public class PlayerCommandEvent extends CancellableEvent {
|
|
|
|
|
2020-07-24 16:11:48 +02:00
|
|
|
private final Player player;
|
2020-04-05 10:15:21 +02:00
|
|
|
private String command;
|
|
|
|
|
2020-10-24 16:33:13 +02:00
|
|
|
public PlayerCommandEvent(@NotNull Player player, @NotNull String command) {
|
2020-04-05 10:15:21 +02:00
|
|
|
this.player = player;
|
|
|
|
this.command = command;
|
|
|
|
}
|
|
|
|
|
2020-05-28 19:15:55 +02:00
|
|
|
/**
|
2020-10-15 21:16:31 +02:00
|
|
|
* Gets the player who sent the command.
|
2020-07-24 16:11:48 +02:00
|
|
|
*
|
|
|
|
* @return the player
|
2020-05-28 19:15:55 +02:00
|
|
|
*/
|
2020-10-24 16:33:13 +02:00
|
|
|
@NotNull
|
2020-04-05 10:15:21 +02:00
|
|
|
public Player getPlayer() {
|
|
|
|
return player;
|
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|