diff --git a/build.gradle b/build.gradle index 92baab2..d760564 100644 --- a/build.gradle +++ b/build.gradle @@ -68,12 +68,12 @@ run { dependencies { implementation('com.github.KaptainWutax:MathUtils:5531c4a87b0f1bb85d1dab2bdd18ce375400626a') { transitive = false } implementation('com.github.KaptainWutax:SeedUtils:b6a383113ce5d8d09a59e91b28ff064fb97c0709') { transitive = false } - implementation('com.github.KaptainWutax:MCUtils:11e3c70867968877233630797741f6cd47777e41') { transitive = false } + implementation('com.github.KaptainWutax:MCUtils:13009755237551c6148cdbda87e8d924c5bfc1ef') { transitive = false } implementation('com.github.KaptainWutax:NoiseUtils:288e1b60e0f427bead80f001d19565ad1adcbd73') { transitive = false } implementation('com.github.KaptainWutax:BiomeUtils:cbb3d433c617087e5a6598ccec3cc0d04bf24e5a') { transitive = false } implementation('com.github.KaptainWutax:TerrainUtils:322c2405600be7e87ded65f7bc6f2c4f042a5472') { transitive = false } - implementation('com.github.KaptainWutax:FeatureUtils:58bde18c79d282ec3bbc955cb76dd5d4b9ad9136') { transitive = false } + implementation('com.github.KaptainWutax:FeatureUtils:ff97b44038b0410cef83cd813b4569ef4a5e4d03') { transitive = false } testImplementation('com.github.KaptainWutax:ChunkRandomReversal:6b76fb5cf2cd438de56e6a46cea2a83985831834') {transitive = false} implementation('com.seedfinding:latticg:1.05') @@ -83,6 +83,7 @@ dependencies { implementation('org.swinglabs.swingx:swingx-core:1.6.5-1') implementation('org.pushing-pixels:radiance-trident:3.5.1') implementation('one.util:streamex:0.7.3') + implementation('com.vdurmont:semver4j:3.1.0') // JOML implementation "org.joml:joml:1.10.1" // LWJGL core diff --git a/gradle.properties b/gradle.properties index 5fd3486..77e5ccd 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,6 @@ # Done to increase the memory available to gradle. org.gradle.jvmargs=-Xmx4G -version=1.0.18 +version=1.0.19 lwjglVersion=3.2.3 diff --git a/src/main/java/kaptainwutax/minemap/MineMap.java b/src/main/java/kaptainwutax/minemap/MineMap.java index 76e5513..396c857 100644 --- a/src/main/java/kaptainwutax/minemap/MineMap.java +++ b/src/main/java/kaptainwutax/minemap/MineMap.java @@ -1,6 +1,7 @@ package kaptainwutax.minemap; import com.formdev.flatlaf.*; +import com.vdurmont.semver4j.Semver; import kaptainwutax.featureutils.misc.SlimeChunk; import kaptainwutax.featureutils.structure.Mineshaft; import kaptainwutax.mcutils.util.data.Pair; @@ -40,6 +41,7 @@ public class MineMap extends JFrame { public static final String version = "@VERSION@"; //using SemVer + public static final Semver semver = new Semver(version); public final static String ROOT_DIR = System.getProperty("user.home") + File.separatorChar + ".minemap"; public final static String LOG_DIR = ROOT_DIR + File.separatorChar + "logs"; public final static String SETTINGS_DIR = ROOT_DIR + File.separatorChar + "configs"; diff --git a/src/main/java/kaptainwutax/minemap/config/UserProfileConfig.java b/src/main/java/kaptainwutax/minemap/config/UserProfileConfig.java index f7b1d69..9f09850 100644 --- a/src/main/java/kaptainwutax/minemap/config/UserProfileConfig.java +++ b/src/main/java/kaptainwutax/minemap/config/UserProfileConfig.java @@ -1,6 +1,7 @@ package kaptainwutax.minemap.config; import com.google.gson.annotations.Expose; +import com.vdurmont.semver4j.Semver; import kaptainwutax.featureutils.misc.SlimeChunk; import kaptainwutax.featureutils.structure.Mineshaft; import kaptainwutax.featureutils.structure.NetherFossil; @@ -16,6 +17,7 @@ import java.io.IOException; import java.util.*; import java.util.concurrent.LinkedBlockingQueue; +import java.util.function.Function; import java.util.stream.Collectors; public class UserProfileConfig extends Config { @@ -189,8 +191,8 @@ protected void resetConfig() { @Override public Config readConfig() { UserProfileConfig config = (UserProfileConfig) super.readConfig(); - config.RECENT_SEEDS = resizeQueue(config.RECENT_SEEDS, MAX_SIZE); - config.SAVED_SEEDS = resizeQueue(config.SAVED_SEEDS, MAX_SIZE); + config.RECENT_SEEDS = resizeQueue(config.RECENT_SEEDS, MAX_SIZE, e -> e); + config.SAVED_SEEDS = resizeQueue(config.SAVED_SEEDS, MAX_SIZE, e -> updateSavedSeeds(this.MINEMAP_VERSION, e)); return config; } @@ -200,6 +202,7 @@ public void maintainConfig() { this.MC_VERSION = this.MC_VERSION == null ? MCVersion.values()[0] : this.MC_VERSION; this.USER_SETTINGS = this.USER_SETTINGS == null ? new UserSettings() : this.USER_SETTINGS; this.OLD_MINEMAP_VERSION = this.OLD_MINEMAP_VERSION == null ? this.MINEMAP_VERSION : this.OLD_MINEMAP_VERSION; + String previousVersion = this.MINEMAP_VERSION; this.MINEMAP_VERSION = MineMap.version; //this.ASSET_VERSION=this.ASSET_VERSION; // allowed since I use null as an invalid version for (Dimension dimension : Dimension.values()) { @@ -221,17 +224,31 @@ public void maintainConfig() { MapSettings settings = this.DEFAULT_MAP_SETTINGS.get(dimension.getName()); settings.maintainConfig(dimension, this.MC_VERSION); } - this.RECENT_SEEDS = resizeQueue(this.RECENT_SEEDS, MAX_SIZE); - this.SAVED_SEEDS = resizeQueue(this.SAVED_SEEDS, MAX_SIZE); + this.RECENT_SEEDS = resizeQueue(this.RECENT_SEEDS, MAX_SIZE, e -> e); + this.SAVED_SEEDS = resizeQueue(this.SAVED_SEEDS, MAX_SIZE, e -> updateSavedSeeds(previousVersion, e)); + } + + private String updateSavedSeeds(String previousVersion, String e) { + if (previousVersion==null || new Semver(previousVersion).isGreaterThan("1.0.18")) return e; + String[] split = e.split("::"); + if (split.length == 3) { + if (split[2].equals("-1")) { + split[2] = "1"; + } else if (split[2].equals("1")) { + split[2] = "-1"; + } + } + return String.join("::", split); } @SuppressWarnings("unchecked") - private static LinkedBlockingQueue resizeQueue(LinkedBlockingQueue queue, int size) { + private static LinkedBlockingQueue resizeQueue(LinkedBlockingQueue queue, int size, Function function) { Object[] recentSeeds = queue.toArray(); queue.clear(); queue = new LinkedBlockingQueue<>(MAX_SIZE); for (int i = 0; i < Math.min(size, recentSeeds.length); i++) { - if (!queue.offer((T) recentSeeds[i])) Logger.LOGGER.severe("The Queue is not sized correctly " + i + " " + MAX_SIZE + " " + queue.size() + " " + Arrays.toString(queue.toArray())); + if (!queue.offer(function.apply((T) recentSeeds[i]))) + Logger.LOGGER.severe("The Queue is not sized correctly " + i + " " + MAX_SIZE + " " + queue.size() + " " + Arrays.toString(queue.toArray())); } return queue; }