From ba448b5670946d4a744009320cdc9b758ad368cb Mon Sep 17 00:00:00 2001 From: xxyy Date: Mon, 19 Oct 2015 00:50:59 +0200 Subject: [PATCH] Add configurable proxy command logging. This commit adds a config switch that allows users to turn off the logging of proxy commands. It is set to off by default to prevent unwanted log spam and keep current behaviour. Log proxy commands This commit changes the PluginManager to print a message to console and the log when a proxy command is executed. This may assist with debugging and miscellaneous investigations. --- api/src/main/java/net/md_5/bungee/api/ProxyConfig.java | 5 +++++ .../java/net/md_5/bungee/api/plugin/PluginManager.java | 7 +++++++ .../src/main/java/net/md_5/bungee/conf/Configuration.java | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java index b638a14f..edd82c1e 100644 --- a/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java +++ b/api/src/main/java/net/md_5/bungee/api/ProxyConfig.java @@ -40,6 +40,11 @@ public interface ProxyConfig */ boolean isOnlineMode(); + /** + * Whether proxy commands are logged to the proxy log + */ + boolean isLogCommands(); + /** * Returns the player max. */ diff --git a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java index cde82027..c7bfddce 100644 --- a/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java +++ b/api/src/main/java/net/md_5/bungee/api/plugin/PluginManager.java @@ -159,6 +159,13 @@ public class PluginManager { if ( tabResults == null ) { + if ( proxy.getConfig().isLogCommands() ) + { + proxy.getLogger().log( Level.INFO, "{0} executed command: /{1}", new Object[] + { + sender.getName(), commandLine + } ); + } command.execute( sender, args ); } else if ( commandLine.contains( " " ) && command instanceof TabExecutor ) { diff --git a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java index 97e00039..7d52931e 100644 --- a/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java +++ b/proxy/src/main/java/net/md_5/bungee/conf/Configuration.java @@ -47,6 +47,10 @@ public class Configuration implements ProxyConfig * Should we check minecraft.net auth. */ private boolean onlineMode = true; + /** + * Whether we log proxy commands to the proxy log + */ + private boolean logCommands; private int playerLimit = -1; private Collection disabledCommands; private int throttle = 4000; @@ -75,6 +79,7 @@ public class Configuration implements ProxyConfig timeout = adapter.getInt( "timeout", timeout ); uuid = adapter.getString( "stats", uuid ); onlineMode = adapter.getBoolean( "online_mode", onlineMode ); + logCommands = adapter.getBoolean( "log_commands", logCommands ); playerLimit = adapter.getInt( "player_limit", playerLimit ); throttle = adapter.getInt( "connection_throttle", throttle ); ipForward = adapter.getBoolean( "ip_forward", ipForward );