diff --git a/src/main/java/net/coreprotect/database/logger/BlockBreakLogger.java b/src/main/java/net/coreprotect/database/logger/BlockBreakLogger.java index 9d3b787..c5fd2c6 100644 --- a/src/main/java/net/coreprotect/database/logger/BlockBreakLogger.java +++ b/src/main/java/net/coreprotect/database/logger/BlockBreakLogger.java @@ -42,7 +42,8 @@ public class BlockBreakLogger { } if (!user.startsWith("#")) { - CacheHandler.spreadCache.remove(location); + String cacheId = location.getBlockX() + "." + location.getBlockY() + "." + location.getBlockZ() + "." + Util.getWorldId(location.getWorld().getName()); + CacheHandler.spreadCache.remove(cacheId); } if (checkType == Material.LECTERN) { diff --git a/src/main/java/net/coreprotect/listener/block/BlockFromToListener.java b/src/main/java/net/coreprotect/listener/block/BlockFromToListener.java index 9eb797a..02a8ab8 100644 --- a/src/main/java/net/coreprotect/listener/block/BlockFromToListener.java +++ b/src/main/java/net/coreprotect/listener/block/BlockFromToListener.java @@ -75,10 +75,10 @@ public final class BlockFromToListener extends Queue implements Listener { } if (f.startsWith("#")) { - Location location = toBlock.getLocation(); + String cacheId = toBlock.getX() + "." + toBlock.getY() + "." + toBlock.getZ() + "." + Util.getWorldId(toBlock.getWorld().getName()); int timestamp = (int) (System.currentTimeMillis() / 1000L); - Object[] cacheData = CacheHandler.spreadCache.get(location); - CacheHandler.spreadCache.put(location, new Object[] { timestamp, type }); + Object[] cacheData = CacheHandler.spreadCache.get(cacheId); + CacheHandler.spreadCache.put(cacheId, new Object[] { timestamp, type }); if (toBlockState == null && cacheData != null && ((Material) cacheData[1]) == type) { return; } diff --git a/src/main/java/net/coreprotect/listener/block/BlockSpreadListener.java b/src/main/java/net/coreprotect/listener/block/BlockSpreadListener.java index 5769efc..1b06824 100644 --- a/src/main/java/net/coreprotect/listener/block/BlockSpreadListener.java +++ b/src/main/java/net/coreprotect/listener/block/BlockSpreadListener.java @@ -82,14 +82,15 @@ public final class BlockSpreadListener extends Queue implements Listener { } private boolean checkCacheData(Block block, Material type) { - int log = 0; - String cacheId = block.getX() + "." + block.getY() + "." + block.getZ() + "." + Util.getWorldId(block.getWorld().getName()) + "." + type.name(); - if (CacheHandler.spreadCache.get(cacheId) == null) { - log = 1; - } + String cacheId = block.getX() + "." + block.getY() + "." + block.getZ() + "." + Util.getWorldId(block.getWorld().getName()); + Location location = block.getLocation(); int timestamp = (int) (System.currentTimeMillis() / 1000L); - CacheHandler.spreadCache.put(cacheId, new Object[] { timestamp }); + Object[] cacheData = CacheHandler.spreadCache.get(cacheId); + CacheHandler.spreadCache.put(cacheId, new Object[] { timestamp, type }); + if (cacheData != null && ((Material) cacheData[1]) == type) { + return true; + } - return (log == 0); + return false; } }