Minestom/src/main/java/net/minestom/server/command/CommandSender.java

49 lines
1.0 KiB
Java
Raw Normal View History

2020-06-21 14:01:03 +02:00
package net.minestom.server.command;
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
*/
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
*/
default boolean isConsole() {
return this instanceof ConsoleSender;
}
2020-06-21 14:01:03 +02:00
}