Added logging for destruction of suspicious sand/gravel

This commit is contained in:
Intelli 2023-07-12 16:26:38 -06:00
parent d414db1c0b
commit e0d65453b6
4 changed files with 19 additions and 4 deletions

View File

@ -201,4 +201,9 @@ public class BukkitAdapter implements BukkitInterface {
return material; return material;
} }
@Override
public boolean hasGravity(Material scanType) {
return scanType.hasGravity();
}
} }

View File

@ -63,4 +63,6 @@ public interface BukkitInterface {
public Material getPlantSeeds(Material material); public Material getPlantSeeds(Material material);
public boolean hasGravity(Material scanType);
} }

View File

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

View File

@ -126,7 +126,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 (scanType.hasGravity()) { if (BukkitAdapter.ADAPTER.hasGravity(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;
@ -134,7 +134,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 (!topMaterial.hasGravity()) { if (!BukkitAdapter.ADAPTER.hasGravity(topMaterial)) {
scanLocation = new Location(world, x, (scanY - 1), z); scanLocation = new Location(world, x, (scanY - 1), z);
topFound = true; topFound = true;
} }
@ -210,7 +210,7 @@ public final class BlockBreakListener extends Queue implements Listener {
} }
} }
else if (scanMin == 5) { else if (scanMin == 5) {
if (scanType.hasGravity()) { if (BukkitAdapter.ADAPTER.hasGravity(scanType)) {
log = true; log = true;
} }
} }
@ -326,7 +326,10 @@ public final class BlockBreakListener extends Queue implements Listener {
} }
for (Block placementBlock : placementMap) { for (Block placementBlock : placementMap) {
queueBlockPlace(user, block.getState(), placementBlock.getType(), null, null, -1, 0, placementBlock.getBlockData().getAsString()); Material placementType = placementBlock.getType();
if (placementType.hasGravity()) {
queueBlockPlace(user, block.getState(), placementType, null, null, -1, 0, placementBlock.getBlockData().getAsString());
}
} }
} }