Unverified Commit 4f015c10 authored by Kawaa's avatar Kawaa Committed by GitHub
Browse files

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: default avatarMelledy <52122272+Melledy@users.noreply.github.com>
parent bab6e684
......@@ -4,8 +4,12 @@ import emu.grasscutter.Grasscutter;
import emu.grasscutter.game.player.Player;
import org.reflections.Reflections;
import java.net.IDN;
import java.util.*;
import static emu.grasscutter.config.Configuration.ACCOUNT;
import static emu.grasscutter.config.Configuration.SERVER;
@SuppressWarnings({"UnusedReturnValue", "unused"})
public final class CommandMap {
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.
*/
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();
if (rawMessage.length() == 0) {
CommandHandler.sendTranslatedMessage(player, "commands.generic.not_specified");
......
......@@ -95,6 +95,7 @@ public class ConfigContainer {
public Set<Integer> debugWhitelist = Set.of();
public Set<Integer> debugBlacklist = Set.of();
public ServerRunMode runMode = ServerRunMode.HYBRID;
public boolean logCommands = false;
public HTTP http = new HTTP();
public Game game = new Game();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment