Added logging for brushing suspicious blocks (implement #409)

This commit is contained in:
Intelli 2023-07-14 14:29:36 -06:00
parent 36ad62007f
commit 05aebe7544
5 changed files with 19 additions and 8 deletions

View file

@ -208,8 +208,8 @@ public class BukkitAdapter implements BukkitInterface {
} }
@Override @Override
public boolean hasGravity(Material scanType) { public boolean isSuspiciousBlock(Material material) {
return scanType.hasGravity(); return false;
} }
@Override @Override

View file

@ -66,7 +66,7 @@ public interface BukkitInterface {
public Material getPlantSeeds(Material material); public Material getPlantSeeds(Material material);
public boolean hasGravity(Material scanType); public boolean isSuspiciousBlock(Material material);
public boolean isSign(Material material); public boolean isSign(Material material);

View file

@ -112,8 +112,8 @@ public class Bukkit_v1_20 extends Bukkit_v1_19 implements BukkitInterface {
} }
@Override @Override
public boolean hasGravity(Material scanType) { public boolean isSuspiciousBlock(Material material) {
return scanType.hasGravity() || scanType == Material.SUSPICIOUS_GRAVEL || scanType == Material.SUSPICIOUS_SAND; return material == Material.SUSPICIOUS_GRAVEL || material == Material.SUSPICIOUS_SAND;
} }
@Override @Override

View file

@ -125,7 +125,7 @@ public final class BlockBreakListener extends Queue implements Listener {
Block scanBlock = world.getBlockAt(scanLocation); Block scanBlock = world.getBlockAt(scanLocation);
Material scanType = scanBlock.getType(); Material scanType = scanBlock.getType();
if (scanMin == 5) { if (scanMin == 5) {
if (BukkitAdapter.ADAPTER.hasGravity(scanType)) { if (scanType.hasGravity() || BukkitAdapter.ADAPTER.isSuspiciousBlock(scanType)) {
if (Config.getConfig(world).BLOCK_MOVEMENT) { if (Config.getConfig(world).BLOCK_MOVEMENT) {
// log the top-most sand/gravel block as being removed // log the top-most sand/gravel block as being removed
int scanY = y + 2; int scanY = y + 2;
@ -133,7 +133,7 @@ public final class BlockBreakListener extends Queue implements Listener {
while (!topFound) { while (!topFound) {
Block topBlock = world.getBlockAt(x, scanY, z); Block topBlock = world.getBlockAt(x, scanY, z);
Material topMaterial = topBlock.getType(); Material topMaterial = topBlock.getType();
if (!BukkitAdapter.ADAPTER.hasGravity(topMaterial)) { if (!topMaterial.hasGravity() && !BukkitAdapter.ADAPTER.isSuspiciousBlock(topMaterial)) {
scanLocation = new Location(world, x, (scanY - 1), z); scanLocation = new Location(world, x, (scanY - 1), z);
topFound = true; topFound = true;
} }
@ -209,7 +209,7 @@ public final class BlockBreakListener extends Queue implements Listener {
} }
} }
else if (scanMin == 5) { else if (scanMin == 5) {
if (BukkitAdapter.ADAPTER.hasGravity(scanType)) { if (scanType.hasGravity() || BukkitAdapter.ADAPTER.isSuspiciousBlock(scanType)) {
log = true; log = true;
} }
} }

View file

@ -751,6 +751,17 @@ public final class PlayerInteractListener extends Queue implements Listener {
} }
} }
} }
else if (BukkitAdapter.ADAPTER.isSuspiciousBlock(type)) {
BlockState blockState = block.getState();
Scheduler.scheduleSyncDelayedTask(CoreProtect.getInstance(), () -> {
Material newType = block.getType();
if (type == newType || (type != Material.SAND && type != Material.GRAVEL)) {
return;
}
Queue.queueBlockPlace(player.getName(), blockState, newType, blockState, newType, -1, 0, null);
}, block.getLocation(), 100);
}
else if (type == Material.DRAGON_EGG) { else if (type == Material.DRAGON_EGG) {
clickedDragonEgg(player, block); clickedDragonEgg(player, block);
} }