From e0d65453b63b04e34aaaa9373b256aa9c0c4080b Mon Sep 17 00:00:00 2001 From: Intelli Date: Wed, 12 Jul 2023 16:26:38 -0600 Subject: [PATCH] Added logging for destruction of suspicious sand/gravel --- .../java/net/coreprotect/bukkit/BukkitAdapter.java | 5 +++++ .../java/net/coreprotect/bukkit/BukkitInterface.java | 2 ++ .../java/net/coreprotect/bukkit/Bukkit_v1_20.java | 5 +++++ .../listener/block/BlockBreakListener.java | 11 +++++++---- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java b/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java index 2117c7a1..092445a8 100644 --- a/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java +++ b/src/main/java/net/coreprotect/bukkit/BukkitAdapter.java @@ -201,4 +201,9 @@ public Material getPlantSeeds(Material material) { return material; } + @Override + public boolean hasGravity(Material scanType) { + return scanType.hasGravity(); + } + } diff --git a/src/main/java/net/coreprotect/bukkit/BukkitInterface.java b/src/main/java/net/coreprotect/bukkit/BukkitInterface.java index 29c922f8..71c01d2b 100644 --- a/src/main/java/net/coreprotect/bukkit/BukkitInterface.java +++ b/src/main/java/net/coreprotect/bukkit/BukkitInterface.java @@ -63,4 +63,6 @@ public interface BukkitInterface { public Material getPlantSeeds(Material material); + public boolean hasGravity(Material scanType); + } diff --git a/src/main/java/net/coreprotect/bukkit/Bukkit_v1_20.java b/src/main/java/net/coreprotect/bukkit/Bukkit_v1_20.java index 56ceb0ad..831a3770 100644 --- a/src/main/java/net/coreprotect/bukkit/Bukkit_v1_20.java +++ b/src/main/java/net/coreprotect/bukkit/Bukkit_v1_20.java @@ -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; + } + } diff --git a/src/main/java/net/coreprotect/listener/block/BlockBreakListener.java b/src/main/java/net/coreprotect/listener/block/BlockBreakListener.java index d1a3c99d..b7f8863a 100644 --- a/src/main/java/net/coreprotect/listener/block/BlockBreakListener.java +++ b/src/main/java/net/coreprotect/listener/block/BlockBreakListener.java @@ -126,7 +126,7 @@ 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; @@ -134,7 +134,7 @@ protected static void processBlockBreak(Player player, String user, Block block, 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; } @@ -210,7 +210,7 @@ else if (!isAttached(block, scanBlock, scanMin)) { } } else if (scanMin == 5) { - if (scanType.hasGravity()) { + if (BukkitAdapter.ADAPTER.hasGravity(scanType)) { log = true; } } @@ -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()); + } } }