mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-22 01:55:34 +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 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<>();
|
||||
@ -164,9 +168,9 @@ public final class CommandMap {
|
||||
|
||||
private boolean setPlayerTarget(String playerId, Player player, String targetUid) {
|
||||
if (targetUid.equals("")) { // Clears the default targetPlayer.
|
||||
targetPlayerIds.remove(playerId);
|
||||
CommandHandler.sendTranslatedMessage(player, "commands.execution.clear_target");
|
||||
return true;
|
||||
targetPlayerIds.remove(playerId);
|
||||
CommandHandler.sendTranslatedMessage(player, "commands.execution.clear_target");
|
||||
return true;
|
||||
}
|
||||
|
||||
// Sets default targetPlayer to the UID provided.
|
||||
@ -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");
|
||||
@ -218,7 +231,7 @@ public final class CommandMap {
|
||||
targetUidStr = targetUidStr.substring(1);
|
||||
}
|
||||
this.setPlayerTarget(playerId, player, targetUidStr);
|
||||
return;
|
||||
return;
|
||||
} else {
|
||||
this.setPlayerTarget(playerId, player, "");
|
||||
return;
|
||||
|
@ -95,7 +95,8 @@ 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();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user