Grasscutter/src/main/java/emu/grasscutter/command/CommandHandler.java

36 lines
1.1 KiB
Java
Raw Normal View History

package emu.grasscutter.command;
import emu.grasscutter.Grasscutter;
2022-04-27 12:24:25 +08:00
import emu.grasscutter.game.player.Player;
2022-05-18 00:24:01 +08:00
import emu.grasscutter.server.event.game.CommandResponseEvent;
import emu.grasscutter.server.event.types.ServerEvent;
import java.util.List;
public interface CommandHandler {
2022-05-08 10:33:53 +08:00
/**
* Send a message to the target.
*
* @param player The player to send the message to, or null for the server console.
* @param message The message to send.
*/
static void sendMessage(Player player, String message) {
if (player == null) {
Grasscutter.getLogger().info(message);
} else {
player.dropMessage(message);
}
2022-05-18 00:24:01 +08:00
CommandResponseEvent event = new CommandResponseEvent(ServerEvent.Type.GAME,player, message);
event.call();
}
2022-04-21 00:17:56 +08:00
/**
* Called when a player/console invokes a command.
* @param sender The player/console that invoked the command.
* @param args The arguments to the command.
*/
2022-05-04 14:32:09 +08:00
default void execute(Player sender, Player targetPlayer, List<String> args) {
}
}