From beb95a288d09b3b85bd31c069aa4ac6de818cb53 Mon Sep 17 00:00:00 2001
From: TechnicJelle <22576047+TechnicJelle@users.noreply.github.com>
Date: Tue, 18 Jun 2024 04:50:04 +0200
Subject: [PATCH] "Rebase" on BMNativeTemplate v0.2
---
pom.xml | 14 ++++++-------
.../BlueMapSpawnMarker.java | 20 +++++++++----------
.../BlueMapSpawnMarker/Config.java | 7 +++----
3 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/pom.xml b/pom.xml
index 49648be..e33b3a1 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
com.technicjelle
BlueMapSpawnMarker
- 0.1
+ 0.2
16
@@ -24,15 +24,15 @@
com.technicjelle.BMUtils
- com.technicjelle.BlueMapSpawnMarker.shade.BMUtils
+ ${project.groupId}.${project.artifactId}.shade.BMUtils
com.technicjelle.UpdateChecker
- com.technicjelle.BlueMapSpawnMarker.shade.UpdateChecker
+ ${project.groupId}.${project.artifactId}.shade.UpdateChecker
org.spongepowered.configurate
- com.technicjelle.BlueMapSpawnMarker.shade.configurate
+ ${project.groupId}.${project.artifactId}.shade.configurate
@@ -96,18 +96,18 @@
com.github.TechnicJelle
UpdateCheckerJava
- v2.3
+ v2.5
de.bluecolored.bluemap
BlueMapCommon
- 5.1
+ 5.2
provided
com.github.TechnicJelle
BMUtils
- v4.1
+ v4.2
compile
diff --git a/src/main/java/com/technicjelle/BlueMapSpawnMarker/BlueMapSpawnMarker.java b/src/main/java/com/technicjelle/BlueMapSpawnMarker/BlueMapSpawnMarker.java
index efe0cf8..c61c675 100644
--- a/src/main/java/com/technicjelle/BlueMapSpawnMarker/BlueMapSpawnMarker.java
+++ b/src/main/java/com/technicjelle/BlueMapSpawnMarker/BlueMapSpawnMarker.java
@@ -2,7 +2,8 @@
import com.flowpowered.math.vector.Vector3i;
import com.technicjelle.BMUtils.BMCopy;
-import com.technicjelle.BMUtils.BMNative;
+import com.technicjelle.BMUtils.BMNative.BMNLogger;
+import com.technicjelle.BMUtils.BMNative.BMNMetadata;
import com.technicjelle.UpdateChecker;
import de.bluecolored.bluemap.api.BlueMapAPI;
import de.bluecolored.bluemap.api.BlueMapMap;
@@ -13,10 +14,9 @@
import java.io.IOException;
import java.util.function.Consumer;
-import java.util.logging.Logger;
public class BlueMapSpawnMarker implements Runnable {
- private Logger logger;
+ private BMNLogger logger;
private UpdateChecker updateChecker;
@Override
@@ -24,20 +24,20 @@ public void run() {
String addonID;
String addonVersion;
try {
- addonID = BMNative.getAddonID(this.getClass().getClassLoader());
- addonVersion = BMNative.getAddonMetadataKey(this.getClass().getClassLoader(), "version");
+ addonID = BMNMetadata.getAddonID(this.getClass().getClassLoader());
+ addonVersion = BMNMetadata.getKey(this.getClass().getClassLoader(), "version");
+ logger = new BMNLogger(this.getClass().getClassLoader());
} catch (IOException e) {
throw new RuntimeException(e);
}
- logger = Logger.getLogger(addonID);
- logger.log(java.util.logging.Level.INFO, "Starting " + addonID + " " + addonVersion);
- updateChecker = new UpdateChecker("TechnicJelle", "BlueMapSpawnMarker", addonVersion);
+ logger.logInfo("Starting " + addonID + " " + addonVersion);
+ updateChecker = new UpdateChecker("TechnicJelle", addonID, addonVersion);
updateChecker.checkAsync();
BlueMapAPI.onEnable(onEnableListener);
}
final private Consumer onEnableListener = api -> {
- updateChecker.logUpdateMessage(logger);
+ updateChecker.getUpdateMessage().ifPresent(logger::logWarning);
Config config;
try {
@@ -63,7 +63,7 @@ public void run() {
//Add markerSet to all maps
for (BlueMapMap map : world.getMaps()) {
- logger.info("Adding spawn marker to map " + map.getId());
+ logger.logInfo("Adding spawn marker to map " + map.getId());
map.getMarkerSets().put("spawn", markerSet);
}
}
diff --git a/src/main/java/com/technicjelle/BlueMapSpawnMarker/Config.java b/src/main/java/com/technicjelle/BlueMapSpawnMarker/Config.java
index 9c7b90e..a421595 100644
--- a/src/main/java/com/technicjelle/BlueMapSpawnMarker/Config.java
+++ b/src/main/java/com/technicjelle/BlueMapSpawnMarker/Config.java
@@ -2,8 +2,7 @@
import com.flowpowered.math.vector.Vector2i;
import com.flowpowered.math.vector.Vector3i;
-import com.technicjelle.BMUtils.BMCopy;
-import com.technicjelle.BMUtils.BMNative;
+import com.technicjelle.BMUtils.BMNative.BMNConfigDirectory;
import de.bluecolored.bluemap.api.BlueMapAPI;
import de.bluecolored.bluemap.api.markers.MarkerSet;
import de.bluecolored.bluemap.api.markers.POIMarker;
@@ -40,8 +39,8 @@ public class Config {
private @Nullable Double maxDistance;
public static Config load(BlueMapAPI api) throws IOException {
- BMCopy.Native.jarResourceToAllocatedConfigDirectory(api, Config.class.getClassLoader(), fileName, fileName, false);
- Path configDirectory = BMNative.getAllocatedConfigDirectory(api, Config.class.getClassLoader());
+ BMNConfigDirectory.BMNCopy.fromJarResource(api, Config.class.getClassLoader(), fileName, fileName, false);
+ Path configDirectory = BMNConfigDirectory.getAllocatedDirectory(api, Config.class.getClassLoader());
Path configFile = configDirectory.resolve(fileName);
HoconConfigurationLoader loader = HoconConfigurationLoader.builder()