Skip to content

Commit

Permalink
Added logging for destruction of suspicious sand/gravel
Browse files Browse the repository at this point in the history
  • Loading branch information
Intelli committed Jul 12, 2023
1 parent d414db1 commit e0d6545
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/main/java/net/coreprotect/bukkit/BukkitAdapter.java
Original file line number Diff line number Diff line change
Expand Up @@ -201,4 +201,9 @@ public Material getPlantSeeds(Material material) {
return material;
}

@Override
public boolean hasGravity(Material scanType) {
return scanType.hasGravity();
}

}
2 changes: 2 additions & 0 deletions src/main/java/net/coreprotect/bukkit/BukkitInterface.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,6 @@ public interface BukkitInterface {

public Material getPlantSeeds(Material material);

public boolean hasGravity(Material scanType);

}
5 changes: 5 additions & 0 deletions src/main/java/net/coreprotect/bukkit/Bukkit_v1_20.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,9 @@ public Material getPlantSeeds(Material material) {
return material;
}

@Override
public boolean hasGravity(Material scanType) {
return scanType.hasGravity() || scanType == Material.SUSPICIOUS_GRAVEL || scanType == Material.SUSPICIOUS_SAND;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -126,15 +126,15 @@ protected static void processBlockBreak(Player player, String user, Block block,
Block scanBlock = world.getBlockAt(scanLocation);
Material scanType = scanBlock.getType();
if (scanMin == 5) {
if (scanType.hasGravity()) {
if (BukkitAdapter.ADAPTER.hasGravity(scanType)) {
if (Config.getConfig(world).BLOCK_MOVEMENT) {
// log the top-most sand/gravel block as being removed
int scanY = y + 2;
boolean topFound = false;
while (!topFound) {
Block topBlock = world.getBlockAt(x, scanY, z);
Material topMaterial = topBlock.getType();
if (!topMaterial.hasGravity()) {
if (!BukkitAdapter.ADAPTER.hasGravity(topMaterial)) {
scanLocation = new Location(world, x, (scanY - 1), z);
topFound = true;
}
Expand Down Expand Up @@ -210,7 +210,7 @@ else if (!isAttached(block, scanBlock, scanMin)) {
}
}
else if (scanMin == 5) {
if (scanType.hasGravity()) {
if (BukkitAdapter.ADAPTER.hasGravity(scanType)) {
log = true;
}
}
Expand Down Expand Up @@ -326,7 +326,10 @@ else if (!isAttached(block, scanBlock, scanMin)) {
}

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());
}
}
}

Expand Down

0 comments on commit e0d6545

Please sign in to comment.