Skip to content

Commit

Permalink
Added hidden "unknown-user" logging option (default: false) (#397)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
3 people authored Jul 17, 2023
1 parent 2476aa2 commit 1331b8d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/main/java/net/coreprotect/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -196,6 +197,7 @@ private void readValues() {
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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Block block = event.getBlock();
World world = block.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();
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)) {
Expand Down Expand Up @@ -58,7 +59,7 @@ protected void onBlockForm(BlockFormEvent event) {
}
}
if (player.length() > 0) {
boolean log = true;
log = true;
/*
if (newState.getType().equals(Material.COBBLESTONE)) {
log = false;
Expand All @@ -78,6 +79,9 @@ protected void onBlockForm(BlockFormEvent event) {
}
}
}
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());
}
}

}

0 comments on commit 1331b8d

Please sign in to comment.