mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-11-24 12:16:36 +01:00
Fixed block spread cache not always being properly utilized
This commit is contained in:
parent
a239b51ed1
commit
32688c55cf
@ -14,6 +14,7 @@ import net.coreprotect.config.Config;
|
|||||||
import net.coreprotect.consumer.Queue;
|
import net.coreprotect.consumer.Queue;
|
||||||
import net.coreprotect.model.BlockGroup;
|
import net.coreprotect.model.BlockGroup;
|
||||||
import net.coreprotect.thread.CacheHandler;
|
import net.coreprotect.thread.CacheHandler;
|
||||||
|
import net.coreprotect.utility.Util;
|
||||||
|
|
||||||
public final class BlockSpreadListener extends Queue implements Listener {
|
public final class BlockSpreadListener extends Queue implements Listener {
|
||||||
|
|
||||||
@ -81,14 +82,14 @@ public final class BlockSpreadListener extends Queue implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkCacheData(Block block, Material type) {
|
private boolean checkCacheData(Block block, Material type) {
|
||||||
Location location = block.getLocation();
|
int log = 0;
|
||||||
int timestamp = (int) (System.currentTimeMillis() / 1000L);
|
String cacheId = block.getX() + "." + block.getY() + "." + block.getZ() + "." + Util.getWorldId(block.getWorld().getName()) + "." + type.name();
|
||||||
Object[] cacheData = CacheHandler.spreadCache.get(location);
|
if (CacheHandler.spreadCache.get(cacheId) == null) {
|
||||||
CacheHandler.spreadCache.put(location, new Object[] { timestamp, type });
|
log = 1;
|
||||||
if (cacheData != null && ((Material) cacheData[1]) == type) {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
int timestamp = (int) (System.currentTimeMillis() / 1000L);
|
||||||
|
CacheHandler.spreadCache.put(cacheId, new Object[] { timestamp });
|
||||||
|
|
||||||
return false;
|
return (log == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@ public class CacheHandler implements Runnable {
|
|||||||
public static Map<String, Object[]> interactCache = Collections.synchronizedMap(new HashMap<>());
|
public static Map<String, Object[]> interactCache = Collections.synchronizedMap(new HashMap<>());
|
||||||
public static Map<String, Object[]> entityCache = Collections.synchronizedMap(new HashMap<>());
|
public static Map<String, Object[]> entityCache = Collections.synchronizedMap(new HashMap<>());
|
||||||
public static ConcurrentHashMap<String, Object[]> pistonCache = new ConcurrentHashMap<>(16, 0.75f, 2);
|
public static ConcurrentHashMap<String, Object[]> pistonCache = new ConcurrentHashMap<>(16, 0.75f, 2);
|
||||||
public static ConcurrentHashMap<Location, Object[]> spreadCache = new ConcurrentHashMap<>(16, 0.75f, 2);
|
public static ConcurrentHashMap<String, Object[]> spreadCache = new ConcurrentHashMap<>(16, 0.75f, 2);
|
||||||
public static ConcurrentHashMap<Location, Object[]> redstoneCache = new ConcurrentHashMap<>(16, 0.75f, 2);
|
public static ConcurrentHashMap<Location, Object[]> redstoneCache = new ConcurrentHashMap<>(16, 0.75f, 2);
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||||
@ -41,7 +41,7 @@ public class CacheHandler implements Runnable {
|
|||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
cache = CacheHandler.spreadCache;
|
cache = CacheHandler.spreadCache;
|
||||||
scanTime = 900; // 15 minutes
|
scanTime = 1800; // 30 minutes
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
cache = CacheHandler.interactCache;
|
cache = CacheHandler.interactCache;
|
||||||
|
Loading…
Reference in New Issue
Block a user