Added hidden "unknown-user" logging option (default: false) (#397)

* Allow unknown user logging (attempt to patch a bug of tnt splashing blocks and it not being logged)

* Changed "unknown-logging" to be hidden (default: false)

* Update BlockFormListener.java

---------

Co-authored-by: Radiant <i.like.using.discord@gmail.com>
Co-authored-by: Intelli <6790859+Intelli@users.noreply.github.com>
This commit is contained in:
Radiant 2023-07-18 02:25:35 +03:00 committed by GitHub
parent 2476aa2ea8
commit 1331b8d0c5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 4 deletions

View File

@ -86,6 +86,7 @@ public class Config extends Language {
public boolean PLAYER_MESSAGES;
public boolean PLAYER_COMMANDS;
public boolean PLAYER_SESSIONS;
public boolean UNKNOWN_LOGGING;
public boolean USERNAME_CHANGES;
public boolean WORLDEDIT;
public int MYSQL_MAXIMUM_POOL_SIZE;
@ -196,6 +197,7 @@ public class Config extends Language {
this.HOPPER_FILTER_META = this.getBoolean("hopper-filter-meta", false);
this.EXCLUDE_TNT = this.getBoolean("exclude-tnt", false);
this.NETWORK_DEBUG = this.getBoolean("network-debug", false);
this.UNKNOWN_LOGGING = this.getBoolean("unknown-logging", false);
this.DONATION_KEY = this.getString("donation-key");
this.MYSQL = this.getBoolean("use-mysql");
this.PREFIX = this.getString("table-prefix");

View File

@ -20,10 +20,11 @@ public final class BlockFormListener extends Queue implements Listener {
@EventHandler(priority = EventPriority.MONITOR)
protected void onBlockForm(BlockFormEvent event) {
// random form, snow/ice
World world = event.getBlock().getWorld();
BlockState newState = event.getNewState();
if (Config.getConfig(world).LIQUID_TRACKING && (newState.getType().equals(Material.OBSIDIAN) || newState.getType().equals(Material.COBBLESTONE) || event.getBlock().getType().name().endsWith("_CONCRETE_POWDER"))) {
Block block = event.getBlock();
World world = block.getWorld();
BlockState newState = event.getNewState();
boolean log = false;
if (Config.getConfig(world).LIQUID_TRACKING && (newState.getType().equals(Material.OBSIDIAN) || newState.getType().equals(Material.COBBLESTONE) || block.getType().name().endsWith("_CONCRETE_POWDER"))) {
String player = Lookup.whoPlacedCache(block);
int wid = Util.getWorldId(world.getName());
if (!(player.length() > 0)) {
@ -58,7 +59,7 @@ public final class BlockFormListener extends Queue implements Listener {
}
}
if (player.length() > 0) {
boolean log = true;
log = true;
/*
if (newState.getType().equals(Material.COBBLESTONE)) {
log = false;
@ -78,6 +79,9 @@ public final class BlockFormListener extends Queue implements Listener {
}
}
}
if (!log && Config.getConfig(world).UNKNOWN_LOGGING && Lookup.whoPlacedCache(block).length() == 0){
Queue.queueBlockPlace("#unknown", block.getLocation().getBlock().getState(), block.getType(), block.getState(), newState.getType(), -1, 0, newState.getBlockData().getAsString());
}
}
}