![JAR search and dependency download from the Maven repository](/logo.png)
net.minestom.server.event.player.PlayerCommandEvent Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.event.player;
import net.minestom.server.entity.Player;
import net.minestom.server.event.trait.CancellableEvent;
import net.minestom.server.event.trait.PlayerInstanceEvent;
import org.jetbrains.annotations.NotNull;
/**
* Called every time a player send a message starting by '/'.
*/
public class PlayerCommandEvent implements PlayerInstanceEvent, CancellableEvent {
private final Player player;
private String command;
private boolean cancelled;
public PlayerCommandEvent(@NotNull Player player, @NotNull String command) {
this.player = player;
this.command = command;
}
/**
* Gets the command used (command name + arguments).
*
* @return the command that the player wants to execute
*/
@NotNull
public String getCommand() {
return command;
}
/**
* Changes the command to execute.
*
* @param command the new command
*/
public void setCommand(@NotNull String command) {
this.command = command;
}
@Override
public boolean isCancelled() {
return cancelled;
}
@Override
public void setCancelled(boolean cancel) {
this.cancelled = cancel;
}
@Override
public @NotNull Player getPlayer() {
return player;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy