diff --git a/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java b/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java index f0f4a99e4..b44474ab7 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/config/VelocityConfiguration.java @@ -346,6 +346,10 @@ public class VelocityConfiguration implements ProxyConfig { return advanced.isFailoverOnUnexpectedServerDisconnect(); } + public boolean isLogCommandExecutions() { + return advanced.isLogCommandExecutions(); + } + @Override public String toString() { return MoreObjects.toStringHelper(this) @@ -582,6 +586,7 @@ public class VelocityConfiguration implements ProxyConfig { private boolean bungeePluginMessageChannel = true; private boolean showPingRequests = false; private boolean failoverOnUnexpectedServerDisconnect = false; + private boolean logCommandExecutions = false; private Advanced() { } @@ -599,6 +604,7 @@ public class VelocityConfiguration implements ProxyConfig { this.showPingRequests = config.getOrElse("show-ping-requests", false); this.failoverOnUnexpectedServerDisconnect = config .getOrElse("failover-on-unexpected-server-disconnect", true); + this.logCommandExecutions = config.getOrElse("log-command-executions", false); } } @@ -642,6 +648,10 @@ public class VelocityConfiguration implements ProxyConfig { return failoverOnUnexpectedServerDisconnect; } + public boolean isLogCommandExecutions() { + return logCommandExecutions; + } + @Override public String toString() { return "Advanced{" @@ -655,6 +665,7 @@ public class VelocityConfiguration implements ProxyConfig { + ", bungeePluginMessageChannel=" + bungeePluginMessageChannel + ", showPingRequests=" + showPingRequests + ", failoverOnUnexpectedServerDisconnect=" + failoverOnUnexpectedServerDisconnect + + ", logCommandExecutions=" + logCommandExecutions + '}'; } } diff --git a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java index 62a1f9225..ec9d9472b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/connection/client/ClientPlaySessionHandler.java @@ -130,6 +130,11 @@ public class ClientPlaySessionHandler implements MinecraftSessionHandler { server.getCommandManager().callCommandEvent(player, msg.substring(1)) .thenComposeAsync(event -> processCommandExecuteResult(originalCommand, event.getResult())) + .whenCompleteAsync((ignored, throwable) -> { + if (server.getConfiguration().isLogCommandExecutions()) { + logger.info("{} -> executed command /{}", player, originalCommand); + } + }) .exceptionally(e -> { logger.info("Exception occurred while running command for {}", player.getUsername(), e); diff --git a/proxy/src/main/resources/default-velocity.toml b/proxy/src/main/resources/default-velocity.toml index a3c31db10..b4e103292 100644 --- a/proxy/src/main/resources/default-velocity.toml +++ b/proxy/src/main/resources/default-velocity.toml @@ -123,6 +123,9 @@ show-ping-requests = false # can disable this setting to use the BungeeCord behavior. failover-on-unexpected-server-disconnect = true +# Enables the logging of commands +log-command-executions = false + [query] # Whether to enable responding to GameSpy 4 query responses or not. enabled = false