1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-03-12 14:49:37 +01:00

lets not add into cache when loading data

This commit is contained in:
Zrips 2019-10-30 10:36:35 +02:00
parent 536eac2613
commit 4cf033618b
3 changed files with 8 additions and 7 deletions

View File

@ -53,12 +53,12 @@ public class BlockProtectionManager {
if (cd == null) if (cd == null)
return; return;
if (cd != -1) if (cd != -1)
addP(loc, System.currentTimeMillis() + (cd * 1000), paid); addP(loc, System.currentTimeMillis() + (cd * 1000), paid, true);
else else
addP(loc, -1L, paid); addP(loc, -1L, paid, true);
} }
public BlockProtection addP(Location loc, Long time, boolean paid) { public BlockProtection addP(Location loc, Long time, boolean paid, boolean cache) {
String v = loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ(); String v = loc.getBlockX() + ":" + loc.getBlockY() + ":" + loc.getBlockZ();
HashMap<String, HashMap<String, HashMap<String, BlockProtection>>> regions = map.get(loc.getWorld()); HashMap<String, HashMap<String, HashMap<String, BlockProtection>>> regions = map.get(loc.getWorld());
if (regions == null) if (regions == null)
@ -85,6 +85,7 @@ 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);
if (cache)
addToCache(loc, Bp); addToCache(loc, Bp);
return Bp; return Bp;
} }

View File

@ -2258,7 +2258,7 @@ public abstract class JobsDAO {
int z = res.getInt(BlockTableFields.z.getCollumn()); int z = res.getInt(BlockTableFields.z.getCollumn());
long resets = res.getLong(BlockTableFields.resets.getCollumn()); long resets = res.getLong(BlockTableFields.resets.getCollumn());
Location loc = new Location(world, x, y, z); Location loc = new Location(world, x, y, z);
BlockProtection bp = Jobs.getBpManager().addP(loc, resets, true); BlockProtection bp = Jobs.getBpManager().addP(loc, resets, true, false);
bp.setId(id); bp.setId(id);
long t = System.currentTimeMillis(); long t = System.currentTimeMillis();
bp.setRecorded(res.getLong(BlockTableFields.recorded.getCollumn())); bp.setRecorded(res.getLong(BlockTableFields.recorded.getCollumn()));

View File

@ -37,7 +37,7 @@ public class PistonProtectionListener implements Listener {
Long bp = Jobs.getBpManager().getTime(oldLoc); Long bp = Jobs.getBpManager().getTime(oldLoc);
if (bp != null) { if (bp != null) {
Jobs.getBpManager().addP(newLoc, bp, true); Jobs.getBpManager().addP(newLoc, bp, true, true);
Jobs.getBpManager().remove(oldLoc); Jobs.getBpManager().remove(oldLoc);
} else { } else {
Integer cd = Jobs.getBpManager().getBlockDelayTime(one); Integer cd = Jobs.getBpManager().getBlockDelayTime(one);
@ -72,7 +72,7 @@ public class PistonProtectionListener implements Listener {
Location newLoc = oldLoc.clone().add(x, y, z); Location newLoc = oldLoc.clone().add(x, y, z);
Long bp = Jobs.getBpManager().getTime(oldLoc); Long bp = Jobs.getBpManager().getTime(oldLoc);
if (bp != null) { if (bp != null) {
Jobs.getBpManager().addP(newLoc, bp, true); Jobs.getBpManager().addP(newLoc, bp, true, true);
Jobs.getBpManager().remove(oldLoc); Jobs.getBpManager().remove(oldLoc);
} else { } else {
Integer cd = Jobs.getBpManager().getBlockDelayTime(one); Integer cd = Jobs.getBpManager().getBlockDelayTime(one);