From cdf2461c395a2d475f83e10b3d3848331a47de20 Mon Sep 17 00:00:00 2001 From: byteful Date: Sat, 29 Jun 2024 22:19:41 +0100 Subject: [PATCH] v1.4.0.2 --- .run/Build.run.xml | 47 +++++++++---------- build.gradle | 4 +- .../api/block/impl/FileBlockDataManager.java | 9 +++- 3 files changed, 33 insertions(+), 27 deletions(-) diff --git a/.run/Build.run.xml b/.run/Build.run.xml index b0dcb5b..b724f4c 100644 --- a/.run/Build.run.xml +++ b/.run/Build.run.xml @@ -1,26 +1,25 @@ - - - - - - true - true - false - - + + + + + + true + true + false + false + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index dc61032..b850597 100644 --- a/build.gradle +++ b/build.gradle @@ -40,7 +40,7 @@ dependencies { implementation 'de.tr7zw:item-nbt-api:2.13.1' implementation 'com.github.Redempt:RedLib:6.6.1' implementation 'com.github.Redempt:Crunch:2.0.3' - implementation 'com.github.cryptomorin:XSeries:11.1.0' + implementation 'com.github.cryptomorin:XSeries:11.2.0' implementation 'com.github.Revxrsal.Lamp:common:3.2.1' implementation 'com.github.Revxrsal.Lamp:bukkit:3.2.1' implementation 'com.github.Sven65:Item-Names:1.0.2' @@ -55,7 +55,7 @@ dependencies { } group = 'me.byteful.plugin' -version = '1.4.0.1' +version = '1.4.0.2' description = 'LevelTools' java.sourceCompatibility = JavaVersion.VERSION_17 diff --git a/src/main/java/me/byteful/plugin/leveltools/api/block/impl/FileBlockDataManager.java b/src/main/java/me/byteful/plugin/leveltools/api/block/impl/FileBlockDataManager.java index fd4cf42..189aaab 100644 --- a/src/main/java/me/byteful/plugin/leveltools/api/block/impl/FileBlockDataManager.java +++ b/src/main/java/me/byteful/plugin/leveltools/api/block/impl/FileBlockDataManager.java @@ -4,9 +4,14 @@ import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; +import java.util.Collections; import java.util.HashSet; +import java.util.Map; import java.util.Set; +import java.util.concurrent.ConcurrentHashMap; import java.util.stream.Collectors; + +import com.google.common.collect.Sets; import me.byteful.plugin.leveltools.api.block.BlockDataManager; import me.byteful.plugin.leveltools.api.block.BlockPosition; import me.byteful.plugin.leveltools.api.scheduler.ScheduledTask; @@ -14,7 +19,8 @@ import me.byteful.plugin.leveltools.util.Text; public class FileBlockDataManager implements BlockDataManager { - private final Set cache = new HashSet<>(); + private static final int MAX_CACHE_SIZE = 10_000; + private final Set cache = ConcurrentHashMap.newKeySet(); private final Path file; private final ScheduledTask saveTask; @@ -45,6 +51,7 @@ public boolean isPlacedBlock(BlockPosition pos) { @Override public void addPlacedBlock(BlockPosition pos) { + if (cache.size() >= MAX_CACHE_SIZE) return; cache.add(pos); }