Skip to content

Commit 5e1e94d

Browse files
committed
Add config option for logging console/RCON commands
1 parent 150dabb commit 5e1e94d

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

Essentials/src/main/java/com/earth2me/essentials/Essentials.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,9 @@ public boolean onCommandEssentials(final CommandSender cSender, final Command co
747747
LOGGER.log(Level.INFO, "CommandBlock at " + bSenderBlock.getX() + "," + bSenderBlock.getY() + "," + bSenderBlock.getZ() + " issued server command: /" + commandLabel + " " + EssentialsCommand.getFinalArg(args, 0));
748748
}
749749
} else if (user == null) {
750-
LOGGER.log(Level.INFO, cSender.getName()+ " issued server command: /" + commandLabel + " " + EssentialsCommand.getFinalArg(args, 0));
750+
if (getSettings().logConsoleRconCommands()) {
751+
LOGGER.log(Level.INFO, cSender.getName()+ " issued server command: /" + commandLabel + " " + EssentialsCommand.getFinalArg(args, 0));
752+
}
751753
}
752754

753755
final CommandSource sender = new CommandSource(this, cSender);

Essentials/src/main/java/com/earth2me/essentials/ISettings.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,8 @@ public interface ISettings extends IConf {
414414

415415
boolean logCommandBlockCommands();
416416

417+
boolean logConsoleRconCommands();
418+
417419
Set<Predicate<String>> getNickBlacklist();
418420

419421
double getMaxProjectileSpeed();

Essentials/src/main/java/com/earth2me/essentials/Settings.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ public class Settings implements net.ess3.api.ISettings {
146146
private boolean isWaterSafe;
147147
private boolean isSafeUsermap;
148148
private boolean logCommandBlockCommands;
149+
private boolean logConsoleRconCommands;
149150
private Set<Predicate<String>> nickBlacklist;
150151
private double maxProjectileSpeed;
151152
private boolean removeEffectsOnHeal;
@@ -930,6 +931,7 @@ public void reloadConfig() {
930931
isWaterSafe = _isWaterSafe();
931932
isSafeUsermap = _isSafeUsermap();
932933
logCommandBlockCommands = _logCommandBlockCommands();
934+
logConsoleRconCommands = _logConsoleRconCommands();
933935
nickBlacklist = _getNickBlacklist();
934936
maxProjectileSpeed = _getMaxProjectileSpeed();
935937
removeEffectsOnHeal = _isRemovingEffectsOnHeal();
@@ -2084,6 +2086,15 @@ public boolean logCommandBlockCommands() {
20842086
return logCommandBlockCommands;
20852087
}
20862088

2089+
private boolean _logConsoleRconCommands() {
2090+
return config.getBoolean("log-console-rcon-commands", true);
2091+
}
2092+
2093+
@Override
2094+
public boolean logConsoleRconCommands() {
2095+
return logConsoleRconCommands;
2096+
}
2097+
20872098
private Set<Predicate<String>> _getNickBlacklist() {
20882099
final Set<Predicate<String>> blacklist = new HashSet<>();
20892100

Essentials/src/main/resources/config.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -769,6 +769,10 @@ safe-usermap-names: true
769769
# Example: CommandBlock at <x>,<y>,<z> issued server command: /<command>
770770
log-command-block-commands: true
771771

772+
# Should Essentials output logs when the console or RCON executes a command?
773+
# Example: CONSOLE issued server command: /<command>
774+
log-console-rcon-commands: true
775+
772776
# Set the maximum speed for projectiles spawned with /fireball.
773777
max-projectile-speed: 8
774778

0 commit comments

Comments
 (0)