mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-11-28 12:55:34 +01:00
Added logging for brushing suspicious blocks (implement #409)
This commit is contained in:
parent
36ad62007f
commit
05aebe7544
@ -208,8 +208,8 @@ public class BukkitAdapter implements BukkitInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGravity(Material scanType) {
|
||||
return scanType.hasGravity();
|
||||
public boolean isSuspiciousBlock(Material material) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -66,7 +66,7 @@ public interface BukkitInterface {
|
||||
|
||||
public Material getPlantSeeds(Material material);
|
||||
|
||||
public boolean hasGravity(Material scanType);
|
||||
public boolean isSuspiciousBlock(Material material);
|
||||
|
||||
public boolean isSign(Material material);
|
||||
|
||||
|
@ -112,8 +112,8 @@ public class Bukkit_v1_20 extends Bukkit_v1_19 implements BukkitInterface {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasGravity(Material scanType) {
|
||||
return scanType.hasGravity() || scanType == Material.SUSPICIOUS_GRAVEL || scanType == Material.SUSPICIOUS_SAND;
|
||||
public boolean isSuspiciousBlock(Material material) {
|
||||
return material == Material.SUSPICIOUS_GRAVEL || material == Material.SUSPICIOUS_SAND;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -125,7 +125,7 @@ public final class BlockBreakListener extends Queue implements Listener {
|
||||
Block scanBlock = world.getBlockAt(scanLocation);
|
||||
Material scanType = scanBlock.getType();
|
||||
if (scanMin == 5) {
|
||||
if (BukkitAdapter.ADAPTER.hasGravity(scanType)) {
|
||||
if (scanType.hasGravity() || BukkitAdapter.ADAPTER.isSuspiciousBlock(scanType)) {
|
||||
if (Config.getConfig(world).BLOCK_MOVEMENT) {
|
||||
// log the top-most sand/gravel block as being removed
|
||||
int scanY = y + 2;
|
||||
@ -133,7 +133,7 @@ public final class BlockBreakListener extends Queue implements Listener {
|
||||
while (!topFound) {
|
||||
Block topBlock = world.getBlockAt(x, scanY, z);
|
||||
Material topMaterial = topBlock.getType();
|
||||
if (!BukkitAdapter.ADAPTER.hasGravity(topMaterial)) {
|
||||
if (!topMaterial.hasGravity() && !BukkitAdapter.ADAPTER.isSuspiciousBlock(topMaterial)) {
|
||||
scanLocation = new Location(world, x, (scanY - 1), z);
|
||||
topFound = true;
|
||||
}
|
||||
@ -209,7 +209,7 @@ public final class BlockBreakListener extends Queue implements Listener {
|
||||
}
|
||||
}
|
||||
else if (scanMin == 5) {
|
||||
if (BukkitAdapter.ADAPTER.hasGravity(scanType)) {
|
||||
if (scanType.hasGravity() || BukkitAdapter.ADAPTER.isSuspiciousBlock(scanType)) {
|
||||
log = true;
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
clickedDragonEgg(player, block);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user