0

I'm running a Vanilla Minecraft: JE Server (v. 1.12.2) and so far so good.

There is only a problem I encountered: griefers. I've already set up a system that logs how many times a player uses a forbidden item (lava bucket, TNT etc...), warns them if they reach a certain limit and, if the user keeps spamming these blocks, adds them to a "team" of banned players that keep getting /kill -ed 'till I ban them properly (this is the closest thing to ban via command blocks). However, one may be able to light a single tree using Flint and Steel, burn a whole forest as the fire propagates and get away with it. So I'd like to have a command block or function print a message to the server console (so it appears in the logs), which would look something like this:

**PlayerName** used FlintAndSteel

Obviously we are talking about a service/technical message so it doesn't have to be pretty at all. What I'd like to have is something to verify which player griefed the server at a certain time, without turning on commandBlockOutput which would otherwise cause massive spam in the server console, considering the amount of Command Blocks and Functions that run every tick.

1
  • First finding: /advancement test @p minecraft:adventure/kill_a_mob creates a log output if /gamerule logAdminCommands true is set, without writing to chat. Now I'll test more and create a proper system. Commented Oct 22, 2017 at 12:14

2 Answers 2

2

Here is one possible solution:

First add a scoreboard to track flint and steel usage (which you probably already have):

/scoreboard objectives add flint stat.useItem.minecraft.flint_and_steel

Then put a ticking command chain in the spawn chunks with these commands in the command blocks:

execute @a[score_flint_min=1] ~ ~ ~ gamerule logAdminCommands true
gamerule logAdminCommands false
scoreboard players set @p[score_flint_min=1] flint 0

The chain command blocks (#2 and #3) can be conditional (and for performance they should).

The first command block temporarily enables debug logging if there is a player with a score of 1 in the "flint" scoreboard (so he used a flint and steel item), which is already the first thing that sends a debug log output to the game log. And because it's executed from the player with the score, the log entry also contains the name of that player.
The second command block then deactivates debug logging again. This already doesn't get sent to the log again, because debug logging is off again.
The third command block resets the "flint" score again. Since debug logging is still off, this doesn't send a message to the log.

So in total you get a log output similar to this every time someone uses a flint and steel:

17:30:08 net.minecraft.server.MinecraftServer [FaRo1: Game rule logAdminCommands has been updated to true]

This looks exactly like when an admin manually enters /gamerule logAdminCommands true into chat, but that shouldn't happen too often and since you probably know the server admin's names, you can see by the name that it wasn't manually entered (because it would have failed). If it is a possible case that you could confuse, then just swap the second and third command in the command block row to get a second output for every flint and steel usage.

You can also put some more command blocks between the first and the second one with additional output. For example you could output the coordinates of the player with a system like this.

Credit for the idea to temporarily activate debug logging and turn it off again afterwards: alex2003super

6
  • they explicitly stated that they don't want to spam their console/logfile
    – Plagiatus
    Commented Oct 22, 2017 at 12:44
  • Then there probably is no way to do it. With gamerule logAdminCommands true, the log contains all executed commands, without, it only contains chat output and log entries made by other stuff, like world opening etc. I'll look into it a bit, but you would probably have to change some setting and change it back to trigger log outputs with gamerule logAdminCommands false. Commented Oct 22, 2017 at 14:10
  • 2
    Would it be possible to enable logging when someone uses FlintNSteel, log the act and re-disable it automatically afterwards using /execute and /gamerule?
    – Manchineel
    Commented Oct 22, 2017 at 14:31
  • Yes, that is possible. Interesting. I'll first finish testing my current idea and then look into that. Commented Oct 22, 2017 at 15:14
  • 1
    It's less than a single tick. It's always just this one command block, because since 1.12, command block chains execute immediately and in a predictable order (the first command block of a different chain starts only after this chain is completely done). Commented Oct 23, 2017 at 5:23
1

I'm afraid there is no good solution to this, as things like /tellraw are not propagated to the server console if logAdminCommands and commandBlockOutput are turned off.

the only thing that still gets put into the server log is a /say command, but everyone on the server will be able to see that, and I doubt you'd want that. But that is the only thing I think could work on vanilla.

2
  • Would a /say executed using /execute be logged?
    – Manchineel
    Commented Oct 22, 2017 at 11:21
  • @alex2003super But /say is always public, so the problem is still there, even when you put it into /execute. Commented Oct 22, 2017 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.