mirror of
https://github.com/Zrips/Jobs.git
synced 2024-12-30 21:07:48 +01:00
BP fix for -1 timers
This commit is contained in:
parent
513fc019fd
commit
fd3c420f08
@ -45,7 +45,7 @@ public class bp implements Cmd {
|
|||||||
Location l = loc.clone().add(x, y, z);
|
Location l = loc.clone().add(x, y, z);
|
||||||
BlockProtection bp = Jobs.getBpManager().getBp(l);
|
BlockProtection bp = Jobs.getBpManager().getBp(l);
|
||||||
if (bp != null) {
|
if (bp != null) {
|
||||||
Long time = bp.getTime();
|
long time = bp.getTime();
|
||||||
if (!all) {
|
if (!all) {
|
||||||
if (bp.getAction() == DBAction.DELETE)
|
if (bp.getAction() == DBAction.DELETE)
|
||||||
continue;
|
continue;
|
||||||
|
@ -16,6 +16,7 @@ import com.gamingmesh.jobs.container.DBAction;
|
|||||||
import net.Zrips.CMILib.Container.CMIBlock;
|
import net.Zrips.CMILib.Container.CMIBlock;
|
||||||
import net.Zrips.CMILib.Container.CMIBlock.Bisect;
|
import net.Zrips.CMILib.Container.CMIBlock.Bisect;
|
||||||
import net.Zrips.CMILib.Items.CMIMaterial;
|
import net.Zrips.CMILib.Items.CMIMaterial;
|
||||||
|
import net.Zrips.CMILib.Logs.CMIDebug;
|
||||||
|
|
||||||
public class BlockProtectionManager {
|
public class BlockProtectionManager {
|
||||||
|
|
||||||
@ -99,7 +100,7 @@ public class BlockProtectionManager {
|
|||||||
Bp.setTime(time);
|
Bp.setTime(time);
|
||||||
|
|
||||||
// If timer is under 2 hours, we can run scheduler to remove it when time comes
|
// 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(), () -> {
|
Bp.setSchedId(Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Jobs.getInstance(), () -> {
|
||||||
remove(loc);
|
remove(loc);
|
||||||
}, (time - System.currentTimeMillis()) / 50));
|
}, (time - System.currentTimeMillis()) / 50));
|
||||||
@ -108,8 +109,9 @@ public class BlockProtectionManager {
|
|||||||
chunks.put(chunk, Bpm);
|
chunks.put(chunk, Bpm);
|
||||||
regions.put(region, chunks);
|
regions.put(region, chunks);
|
||||||
map.put(loc.getWorld(), regions);
|
map.put(loc.getWorld(), regions);
|
||||||
|
|
||||||
// Only saving into save cache if timer is higher than 5 minutes
|
// 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);
|
addToCache(loc, Bp);
|
||||||
return Bp;
|
return Bp;
|
||||||
}
|
}
|
||||||
@ -123,6 +125,7 @@ public class BlockProtectionManager {
|
|||||||
locations = new ConcurrentHashMap<>();
|
locations = new ConcurrentHashMap<>();
|
||||||
tempCache.put(loc.getWorld(), locations);
|
tempCache.put(loc.getWorld(), locations);
|
||||||
}
|
}
|
||||||
|
CMIDebug.d("Cached");
|
||||||
|
|
||||||
locations.put(v, Bp);
|
locations.put(v, Bp);
|
||||||
}
|
}
|
||||||
@ -179,7 +182,7 @@ public class BlockProtectionManager {
|
|||||||
world.remove(locToRegion(loc));
|
world.remove(locToRegion(loc));
|
||||||
|
|
||||||
return bp;
|
return bp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getTime(Block block) {
|
public Long getTime(Block block) {
|
||||||
return getTime(block.getLocation());
|
return getTime(block.getLocation());
|
||||||
|
@ -43,7 +43,7 @@ public class BlockProtection {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static long deconvert(int time) {
|
private static long deconvert(int time) {
|
||||||
return (time * 1000L) + pre;
|
return time == -1 ? -1 : (time * 1000L) + pre;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTime(long time) {
|
public void setTime(long time) {
|
||||||
|
Loading…
Reference in New Issue
Block a user