Skip to content

Commit 9f57b3e

Browse files
imeesaJRoy
andauthored
Add config option for logging console/RCON commands (#6337)
<!-- EssentialsX feature submission guide ==================================== NOTE: Failure to fill out this template properly may result in your PR being delayed or ignored without warning. NOTE: Don't type between any arrows in the template, as this text will be hidden. This includes this header block and any other explanation text blocks. Want to discuss your PR before submitting it? Join the EssentialsX Development server: https://discord.gg/CUN7qVb EssentialsX is GPL ------------------ By contributing to EssentialsX, you agree to license your code under the GNU General Public License version 3, which can be found at the link below: https://github.com/EssentialsX/Essentials/blob/2.x/LICENSE Instructions ------------ If you are submitting a new feature, please follow the following steps: 1. Fill out the template in full. This includes providing screenshots and a link to the original feature request. If there isn't an existing feature request, we strongly recommend opening a new feature request BEFORE opening your PR to implement it, as this allows us to review whether we're likely to accept your feature in advance, and also allows us to discuss possible implementations for the feature. If there is no associated feature request, your PR may be delayed or rejected without warning. You can open a new feature request by following this link: https://github.com/EssentialsX/Essentials/issues/new/choose 2. If you are fixing a performance issue, please use the "Bug fix" PR template instead. The "bug fix" template is better suited to performance issues. 3. Include a demonstration. If you are adding commands, please provide screenshots and/or a video demonstration of the feature. Similarly, if you are adding a new API, please include a link to example code that takes advantage of your proposed API. This will aid us in reviewing PRs and speed up the process significantly. --> ### Information <!-- Replace #nnnn with the number of the original issue. If this PR implements features from multiple issues, you should repeat the phrase "closes #nnnn" for each issue. --> Closes #6336. ### Details <!-- Type a description of your proposed feature below this line. --> This adds a config option that allows disabling the logging of console and RCON commands. **Environments tested:** <!-- Type the OS you have used below. --> OS: Arch Linux <!-- Type the JDK version (from java -version) you have used below. --> Java version: openjdk 21.0.8 2025-07-15 <!-- Put an "x" inside the boxes for the server software you have tested this bug fix on. If this feature does not apply to a server, strike through the server software using ~~strikethrough~~. If you have tested on other environments, add a new line with relevant details. --> - [x] Most recent Paper version (1.XX.Y, git-Paper-BUILD) - [x] CraftBukkit/Spigot/Paper 1.12.2 - [x] CraftBukkit 1.8.8 **Demonstration:** <!-- Below this block, include screenshots/log snippets from before and after as necessary. If you have created or used a test case plugin, please link to a download of the plugin, source code and exact version used where possible. --> Without these changes, with the config option not set: <img width="680" height="69" alt="image" src="https://github.com/user-attachments/assets/92647fc0-c0c5-4e7b-9f61-953fcadd7f93" /> With these changes, with the config option set to false: <img width="635" height="68" alt="image" src="https://github.com/user-attachments/assets/fd11572c-dfe2-4b79-89ab-69e2275d2c9f" /> --------- Co-authored-by: Josh Roy <[email protected]>
1 parent 9985dbd commit 9f57b3e

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().logConsoleCommands()) {
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 logConsoleCommands();
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 logConsoleCommands;
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+
logConsoleCommands = _logConsoleCommands();
933935
nickBlacklist = _getNickBlacklist();
934936
maxProjectileSpeed = _getMaxProjectileSpeed();
935937
removeEffectsOnHeal = _isRemovingEffectsOnHeal();
@@ -2084,6 +2086,15 @@ public boolean logCommandBlockCommands() {
20842086
return logCommandBlockCommands;
20852087
}
20862088

2089+
private boolean _logConsoleCommands() {
2090+
return config.getBoolean("log-console-commands", true);
2091+
}
2092+
2093+
@Override
2094+
public boolean logConsoleCommands() {
2095+
return logConsoleCommands;
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 console executes a command?
773+
# Example: CONSOLE issued server command: /<command>
774+
log-console-commands: true
775+
772776
# Set the maximum speed for projectiles spawned with /fireball.
773777
max-projectile-speed: 8
774778

0 commit comments

Comments
 (0)