From 48e67d0426f9504a74c70f64200c40caf2d0321e Mon Sep 17 00:00:00 2001 From: Zrips Date: Wed, 26 Jun 2024 18:22:32 +0300 Subject: [PATCH] Fix for water removing block protection when we should keep it --- .../com/gamingmesh/jobs/config/BlockProtectionManager.java | 4 ++-- .../gamingmesh/jobs/config/ExploitProtectionManager.java | 3 ++- .../java/com/gamingmesh/jobs/listeners/JobsListener.java | 7 +++++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java b/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java index 49a46c7f..43453e0f 100644 --- a/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java @@ -108,8 +108,8 @@ public class BlockProtectionManager { Bp.setPaid(paid); Bp.setTime(time); - // If timer is under 2 hours, we can run scheduler to remove it when time comes - if (time > -1 && (time - System.currentTimeMillis()) / 1000 < 60 * 60 * 2) + // If timer is under 5 min, we can run scheduler to remove it when time comes + if (time > -1 && (time - System.currentTimeMillis()) / 1000 < 60 * 5) Bp.setScheduler(CMIScheduler.runAtLocationLater(loc, () -> remove(loc), (time - System.currentTimeMillis()) / 50)); Bpm.put(v, Bp); diff --git a/src/main/java/com/gamingmesh/jobs/config/ExploitProtectionManager.java b/src/main/java/com/gamingmesh/jobs/config/ExploitProtectionManager.java index b1095b96..0d08541c 100644 --- a/src/main/java/com/gamingmesh/jobs/config/ExploitProtectionManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/ExploitProtectionManager.java @@ -14,6 +14,7 @@ import net.Zrips.CMILib.ActionBar.CMIActionBar; import net.Zrips.CMILib.Container.CMIBlock; import net.Zrips.CMILib.Container.CMIBlock.Bisect; import net.Zrips.CMILib.Items.CMIMaterial; +import net.Zrips.CMILib.Logs.CMIDebug; import net.Zrips.CMILib.PersistentData.CMIBlockPersistentDataContainer; public class ExploitProtectionManager { @@ -76,7 +77,7 @@ public class ExploitProtectionManager { } public void remove(Block block) { - +CMIDebug.d("remove protection", block.getType()); // In case double plant was destroyed we should remove both blocks from records CMIMaterial cmat = CMIMaterial.get(block); switch (cmat) { diff --git a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java index 23f138cf..d8d0bee3 100644 --- a/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java +++ b/src/main/java/com/gamingmesh/jobs/listeners/JobsListener.java @@ -128,9 +128,12 @@ public class JobsListener implements Listener { if (!Jobs.getGCManager().canPerformActionInWorld(event.getBlock().getWorld())) return; - if (Jobs.getGCManager().useNewBlockProtection) + if (CMIMaterial.isWater(event.getBlock().getType())) + return; + + if (Jobs.getGCManager().useNewBlockProtection) { Jobs.getExploitManager().remove(event.getToBlock()); - else + } else Jobs.getBpManager().remove(event.getToBlock()); }