CommandHandler.java 792 Bytes
Newer Older
KingRainbow44's avatar
KingRainbow44 committed
1
2
3
4
5
6
7
8
9
package emu.grasscutter.commands;

import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.GenshinPlayer;

import java.util.List;

public interface CommandHandler {
    /* Invoked on player execution. */
KingRainbow44's avatar
KingRainbow44 committed
10
    default void execute(GenshinPlayer player, List<String> args) { }
KingRainbow44's avatar
KingRainbow44 committed
11
    /* Invoked on server execution. */
KingRainbow44's avatar
KingRainbow44 committed
12
    default void execute(List<String> args) { }
KingRainbow44's avatar
KingRainbow44 committed
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
    
    /*
     * Utilities.
     */

    /**
     * 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(GenshinPlayer player, String message) {
        if(player == null) {
            Grasscutter.getLogger().info(message);
        } else player.dropMessage(message);
    }
}