mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-25 20:56:28 +00:00
Console output player command (#1722)
* Console output player command * Update CommandMap.java * Add the Output_player_command option to the config * Proper formatting for logging commands * Log account usernames, not player nicknames Co-authored-by: Melledy <52122272+Melledy@users.noreply.github.com>
This commit is contained in:
parent
bab6e6845e
commit
4f015c1077
@ -4,8 +4,12 @@ import emu.grasscutter.Grasscutter;
|
|||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import org.reflections.Reflections;
|
import org.reflections.Reflections;
|
||||||
|
|
||||||
|
import java.net.IDN;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import static emu.grasscutter.config.Configuration.ACCOUNT;
|
||||||
|
import static emu.grasscutter.config.Configuration.SERVER;
|
||||||
|
|
||||||
@SuppressWarnings({"UnusedReturnValue", "unused"})
|
@SuppressWarnings({"UnusedReturnValue", "unused"})
|
||||||
public final class CommandMap {
|
public final class CommandMap {
|
||||||
private final Map<String, CommandHandler> commands = new TreeMap<>();
|
private final Map<String, CommandHandler> commands = new TreeMap<>();
|
||||||
@ -195,6 +199,15 @@ public final class CommandMap {
|
|||||||
* @param rawMessage The messaged used to invoke the command.
|
* @param rawMessage The messaged used to invoke the command.
|
||||||
*/
|
*/
|
||||||
public void invoke(Player player, Player targetPlayer, String rawMessage) {
|
public void invoke(Player player, Player targetPlayer, String rawMessage) {
|
||||||
|
// The console outputs in-game command. [{Account Username} (Player UID: {Player Uid})]
|
||||||
|
if (SERVER.logCommands) {
|
||||||
|
if (player != null) {
|
||||||
|
Grasscutter.getLogger().info("Command used by [" + player.getAccount().getUsername() + " (Player UID: " + player.getUid() + ")]: " + rawMessage);
|
||||||
|
} else {
|
||||||
|
Grasscutter.getLogger().info("Command used by server console: " + rawMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
rawMessage = rawMessage.trim();
|
rawMessage = rawMessage.trim();
|
||||||
if (rawMessage.length() == 0) {
|
if (rawMessage.length() == 0) {
|
||||||
CommandHandler.sendTranslatedMessage(player, "commands.generic.not_specified");
|
CommandHandler.sendTranslatedMessage(player, "commands.generic.not_specified");
|
||||||
|
@ -95,6 +95,7 @@ public class ConfigContainer {
|
|||||||
public Set<Integer> debugWhitelist = Set.of();
|
public Set<Integer> debugWhitelist = Set.of();
|
||||||
public Set<Integer> debugBlacklist = Set.of();
|
public Set<Integer> debugBlacklist = Set.of();
|
||||||
public ServerRunMode runMode = ServerRunMode.HYBRID;
|
public ServerRunMode runMode = ServerRunMode.HYBRID;
|
||||||
|
public boolean logCommands = false;
|
||||||
|
|
||||||
public HTTP http = new HTTP();
|
public HTTP http = new HTTP();
|
||||||
public Game game = new Game();
|
public Game game = new Game();
|
||||||
|
Loading…
Reference in New Issue
Block a user