diff --git a/src/main/java/com/gamingmesh/jobs/commands/list/bp.java b/src/main/java/com/gamingmesh/jobs/commands/list/bp.java index d91e8cb0..d026c992 100644 --- a/src/main/java/com/gamingmesh/jobs/commands/list/bp.java +++ b/src/main/java/com/gamingmesh/jobs/commands/list/bp.java @@ -45,7 +45,7 @@ public class bp implements Cmd { Location l = loc.clone().add(x, y, z); BlockProtection bp = Jobs.getBpManager().getBp(l); if (bp != null) { - Long time = bp.getTime(); + long time = bp.getTime(); if (!all) { if (bp.getAction() == DBAction.DELETE) continue; diff --git a/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java b/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java index 6ab32bde..931d6534 100644 --- a/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java +++ b/src/main/java/com/gamingmesh/jobs/config/BlockProtectionManager.java @@ -16,6 +16,7 @@ import com.gamingmesh.jobs.container.DBAction; 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; public class BlockProtectionManager { @@ -99,7 +100,7 @@ public class BlockProtectionManager { Bp.setTime(time); // If timer is under 2 hours, we can run scheduler to remove it when time comes - if ((time - System.currentTimeMillis()) / 1000 < 60 * 60 * 2) + if (time > -1 && (time - System.currentTimeMillis()) / 1000 < 60 * 60 * 2) Bp.setSchedId(Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Jobs.getInstance(), () -> { remove(loc); }, (time - System.currentTimeMillis()) / 50)); @@ -108,8 +109,9 @@ public class BlockProtectionManager { chunks.put(chunk, Bpm); regions.put(region, chunks); map.put(loc.getWorld(), regions); + // Only saving into save cache if timer is higher than 5 minutes - if (cache && (time - System.currentTimeMillis()) / 1000 > 60 * 5) + if (cache && ((time - System.currentTimeMillis()) / 1000 > 60 * 5 || time < 0) ) addToCache(loc, Bp); return Bp; } @@ -123,6 +125,7 @@ public class BlockProtectionManager { locations = new ConcurrentHashMap<>(); tempCache.put(loc.getWorld(), locations); } + CMIDebug.d("Cached"); locations.put(v, Bp); } @@ -179,7 +182,7 @@ public class BlockProtectionManager { world.remove(locToRegion(loc)); return bp; - } + } public Long getTime(Block block) { return getTime(block.getLocation()); diff --git a/src/main/java/com/gamingmesh/jobs/container/BlockProtection.java b/src/main/java/com/gamingmesh/jobs/container/BlockProtection.java index 44584bb4..b3f0a4b4 100644 --- a/src/main/java/com/gamingmesh/jobs/container/BlockProtection.java +++ b/src/main/java/com/gamingmesh/jobs/container/BlockProtection.java @@ -43,7 +43,7 @@ public class BlockProtection { } private static long deconvert(int time) { - return (time * 1000L) + pre; + return time == -1 ? -1 : (time * 1000L) + pre; } public void setTime(long time) {