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 <10731363+JRoy@users.noreply.github.com>
This commit is contained in:
Eesa 2025-11-09 18:52:34 -05:00 committed by GitHub
parent 9985dbdd3a
commit 9f57b3e476
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 20 additions and 1 deletions

View File

@ -747,7 +747,9 @@ public class Essentials extends JavaPlugin implements net.ess3.api.IEssentials {
LOGGER.log(Level.INFO, "CommandBlock at " + bSenderBlock.getX() + "," + bSenderBlock.getY() + "," + bSenderBlock.getZ() + " issued server command: /" + commandLabel + " " + EssentialsCommand.getFinalArg(args, 0));
}
} else if (user == null) {
LOGGER.log(Level.INFO, cSender.getName()+ " issued server command: /" + commandLabel + " " + EssentialsCommand.getFinalArg(args, 0));
if (getSettings().logConsoleCommands()) {
LOGGER.log(Level.INFO, cSender.getName()+ " issued server command: /" + commandLabel + " " + EssentialsCommand.getFinalArg(args, 0));
}
}
final CommandSource sender = new CommandSource(this, cSender);

View File

@ -414,6 +414,8 @@ public interface ISettings extends IConf {
boolean logCommandBlockCommands();
boolean logConsoleCommands();
Set<Predicate<String>> getNickBlacklist();
double getMaxProjectileSpeed();

View File

@ -146,6 +146,7 @@ public class Settings implements net.ess3.api.ISettings {
private boolean isWaterSafe;
private boolean isSafeUsermap;
private boolean logCommandBlockCommands;
private boolean logConsoleCommands;
private Set<Predicate<String>> nickBlacklist;
private double maxProjectileSpeed;
private boolean removeEffectsOnHeal;
@ -930,6 +931,7 @@ public class Settings implements net.ess3.api.ISettings {
isWaterSafe = _isWaterSafe();
isSafeUsermap = _isSafeUsermap();
logCommandBlockCommands = _logCommandBlockCommands();
logConsoleCommands = _logConsoleCommands();
nickBlacklist = _getNickBlacklist();
maxProjectileSpeed = _getMaxProjectileSpeed();
removeEffectsOnHeal = _isRemovingEffectsOnHeal();
@ -2084,6 +2086,15 @@ public class Settings implements net.ess3.api.ISettings {
return logCommandBlockCommands;
}
private boolean _logConsoleCommands() {
return config.getBoolean("log-console-commands", true);
}
@Override
public boolean logConsoleCommands() {
return logConsoleCommands;
}
private Set<Predicate<String>> _getNickBlacklist() {
final Set<Predicate<String>> blacklist = new HashSet<>();

View File

@ -769,6 +769,10 @@ safe-usermap-names: true
# Example: CommandBlock at <x>,<y>,<z> issued server command: /<command>
log-command-block-commands: true
# Should Essentials output logs when console executes a command?
# Example: CONSOLE issued server command: /<command>
log-console-commands: true
# Set the maximum speed for projectiles spawned with /fireball.
max-projectile-speed: 8