Skip to content

Commit

Permalink
update to 1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
hube12 committed Jun 8, 2021
1 parent 2165be4 commit 65fd3da
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions src/main/java/kaptainwutax/minemap/MineMap.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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";
Expand Down
29 changes: 23 additions & 6 deletions src/main/java/kaptainwutax/minemap/config/UserProfileConfig.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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 {
Expand Down Expand Up @@ -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;
}

Expand All @@ -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()) {
Expand All @@ -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 <T> LinkedBlockingQueue<T> resizeQueue(LinkedBlockingQueue<T> queue, int size) {
private static <T> LinkedBlockingQueue<T> resizeQueue(LinkedBlockingQueue<T> queue, int size, Function<T, T> 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;
}
Expand Down

0 comments on commit 65fd3da

Please sign in to comment.