2020-06-21 14:01:03 +02:00
|
|
|
package net.minestom.server.command;
|
|
|
|
|
2020-06-22 00:48:12 +02:00
|
|
|
import net.minestom.server.entity.Player;
|
|
|
|
|
2020-07-21 18:48:15 +02:00
|
|
|
/**
|
|
|
|
* Represent something which can send commands to the server
|
|
|
|
* <p>
|
|
|
|
* Main implementations are {@link Player} and {@link ConsoleSender}
|
|
|
|
*/
|
2020-06-21 14:01:03 +02:00
|
|
|
public interface CommandSender {
|
|
|
|
|
2020-07-21 18:48:15 +02:00
|
|
|
/**
|
|
|
|
* Send a raw string message
|
|
|
|
*
|
|
|
|
* @param message the message to send
|
|
|
|
*/
|
2020-06-21 14:01:03 +02:00
|
|
|
void sendMessage(String message);
|
|
|
|
|
2020-07-21 18:48:15 +02:00
|
|
|
/**
|
|
|
|
* Send multiple raw string messages
|
|
|
|
*
|
|
|
|
* @param messages the messages to send
|
|
|
|
*/
|
2020-06-21 14:01:03 +02:00
|
|
|
default void sendMessage(String[] messages) {
|
|
|
|
for (String message : messages) {
|
|
|
|
sendMessage(message);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-07-21 18:48:15 +02:00
|
|
|
/**
|
|
|
|
* Get if the sender is a player
|
|
|
|
*
|
|
|
|
* @return true if 'this' is a player, false otherwise
|
|
|
|
*/
|
2020-06-22 00:48:12 +02:00
|
|
|
default boolean isPlayer() {
|
|
|
|
return this instanceof Player;
|
|
|
|
}
|
|
|
|
|
2020-07-21 18:48:15 +02:00
|
|
|
/**
|
|
|
|
* Get if the sender is the console
|
|
|
|
*
|
|
|
|
* @return true if 'this' is the console, false otherwise
|
|
|
|
*/
|
2020-06-22 00:48:12 +02:00
|
|
|
default boolean isConsole() {
|
|
|
|
return this instanceof ConsoleSender;
|
|
|
|
}
|
|
|
|
|
2020-06-21 14:01:03 +02:00
|
|
|
}
|