Skip to content

Commit f7ffd53

Browse files
committed
JM 6 nbt waypoint data container support
1 parent e363d24 commit f7ffd53

File tree

8 files changed

+81
-25
lines changed

8 files changed

+81
-25
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ jobs:
1313
- name: Check out repository
1414
uses: actions/checkout@v4
1515

16-
- name: Gradle Wrapper Verification
17-
uses: gradle/wrapper-validation-action@v3
18-
1916
- name: Set up JDK 8
2017
uses: actions/setup-java@v4
2118
with:
@@ -25,13 +22,16 @@ jobs:
2522
- name: Elevate wrapper permissions
2623
run: chmod +x ./gradlew
2724

28-
- name: Build
29-
uses: gradle/gradle-build-action@v3
25+
- name: Setup Gradle
26+
uses: gradle/actions/setup-gradle@v4
3027
with:
31-
arguments: build
28+
dependency-graph: generate-and-submit
29+
30+
- name: Build
31+
run: ./gradlew build
3232

3333
- name: Upload artifact
3434
uses: actions/upload-artifact@v4
3535
with:
3636
name: JMWaypointsToXaero
37-
path: JMWaypointsToXaero-*.jar
37+
path: build/libs/JMWaypointsToXaero-*.jar

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ This will overwrite any Xaero Waypoints you have defined already for your select
1616

1717
Download the latest jar from releases
1818

19-
`java -jar JMWaypointstoXaero-1.1.jar <input folder> <output folder>`
19+
`java -jar JMWaypointstoXaero-1.2.jar <input folder> <output folder>`
2020

2121
Input folder is your JourneyMap directory for your selected world.
2222

@@ -26,11 +26,11 @@ Example:
2626
Output folder is your destination Xaero Waypoints directory
2727

2828
Example:
29-
`C:\Users\rfresh2\AppData\Roaming\.minecraft\XaeroWaypoints\Multiplayer_2b2t.org`
29+
`C:\Users\rfresh2\AppData\Roaming\.minecraft\xaero\minimap\Multiplayer_2b2t.org`
3030

3131
# Full command example
3232

33-
`java -jar JMWaypointsToXaero-1.1.jar "C:\Users\rfresh2\AppData\Roaming\.minecraft\journeymap\data\mp\2b2t" "C:\Users\rfresh2\AppData\Roaming\.minecraft\XaeroWaypoints\Multiplayer_2b2t.org"`
33+
`java -jar JMWaypointsToXaero-1.1.jar "C:\Users\rfresh2\AppData\Roaming\.minecraft\journeymap\data\mp\2b2t" "C:\Users\rfresh2\AppData\Roaming\.minecraft\xaero\minimap\Multiplayer_2b2t.org"`
3434

3535
# Additional References
3636

build.gradle.kts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
plugins {
22
java
3-
id("io.github.goooler.shadow") version "8.1.7"
3+
id("com.gradleup.shadow") version "8.3.7"
44
}
55

66
group = "com.github.rfresh2"
7-
version = "1.1"
7+
version = "1.2"
88

99
val shade: Configuration by configurations.creating
1010
configurations.implementation.get().extendsFrom(shade)
@@ -15,13 +15,15 @@ java {
1515

1616
repositories {
1717
mavenCentral()
18+
maven("https://repo.viaversion.com")
1819
}
1920

2021
dependencies {
21-
shade("com.fasterxml.jackson.core:jackson-core:2.17.1")
22-
shade("com.fasterxml.jackson.core:jackson-databind:2.17.1")
23-
shade("org.slf4j:slf4j-api:2.0.13")
24-
shade("org.slf4j:slf4j-simple:2.0.13")
22+
shade("com.fasterxml.jackson.core:jackson-core:2.18.4")
23+
shade("com.fasterxml.jackson.core:jackson-databind:2.18.4")
24+
shade("org.slf4j:slf4j-api:2.0.17")
25+
shade("org.slf4j:slf4j-simple:2.0.17")
26+
shade("com.viaversion:nbt:5.1.1")
2527
}
2628

2729
tasks {

gradle/wrapper/gradle-wrapper.jar

311 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
#
18+
# SPDX-License-Identifier: Apache-2.0
19+
#
1820

1921
##############################################################################
2022
#
@@ -55,7 +57,7 @@
5557
# Darwin, MinGW, and NonStop.
5658
#
5759
# (3) This script is generated from the Groovy template
58-
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
60+
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
5961
# within the Gradle project.
6062
#
6163
# You can find Gradle at https://github.com/gradle/gradle/.
@@ -84,7 +86,7 @@ done
8486
# shellcheck disable=SC2034
8587
APP_BASE_NAME=${0##*/}
8688
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
87-
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
89+
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
8890

8991
# Use the maximum available, or set MAX_FD != -1 to use that value.
9092
MAX_FD=maximum
@@ -112,7 +114,7 @@ case "$( uname )" in #(
112114
NONSTOP* ) nonstop=true ;;
113115
esac
114116

115-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
117+
CLASSPATH="\\\"\\\""
116118

117119

118120
# Determine the Java command to use to start the JVM.
@@ -203,15 +205,15 @@ fi
203205
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
204206

205207
# Collect all arguments for the java command:
206-
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
208+
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
207209
# and any embedded shellness will be escaped.
208210
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
209211
# treated as '${Hostname}' itself on the command line.
210212

211213
set -- \
212214
"-Dorg.gradle.appname=$APP_BASE_NAME" \
213215
-classpath "$CLASSPATH" \
214-
org.gradle.wrapper.GradleWrapperMain \
216+
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
215217
"$@"
216218

217219
# Stop when "xargs" is not available.

gradlew.bat

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
@rem See the License for the specific language governing permissions and
1414
@rem limitations under the License.
1515
@rem
16+
@rem SPDX-License-Identifier: Apache-2.0
17+
@rem
1618

1719
@if "%DEBUG%"=="" @echo off
1820
@rem ##########################################################################
@@ -68,11 +70,11 @@ goto fail
6870
:execute
6971
@rem Setup the command line
7072

71-
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73+
set CLASSPATH=
7274

7375

7476
@rem Execute Gradle
75-
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
77+
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
7678

7779
:end
7880
@rem End local scope for the variables with windows NT shell

src/main/java/com/github/rfresh2/JourneyMapWaypointsToXaero.java

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
import com.github.rfresh2.model.JMWaypointLegacy;
1010
import com.github.rfresh2.model.JMWaypointModern;
1111
import com.github.rfresh2.model.XaeroWaypoint;
12+
import com.viaversion.nbt.io.NBTIO;
13+
import com.viaversion.nbt.tag.CompoundTag;
14+
import com.viaversion.nbt.tag.Tag;
1215
import org.slf4j.Logger;
1316
import org.slf4j.LoggerFactory;
1417

@@ -20,6 +23,7 @@
2023
import java.nio.file.OpenOption;
2124
import java.nio.file.Path;
2225
import java.nio.file.StandardOpenOption;
26+
import java.util.ArrayList;
2327
import java.util.Arrays;
2428
import java.util.List;
2529
import java.util.Objects;
@@ -60,7 +64,31 @@ public static void main(final String[] args) {
6064
}
6165

6266
private static List<XaeroWaypoint> convertWaypoints(Path inputFolder) {
63-
return Arrays.stream(Objects.requireNonNull(inputFolder.toFile().listFiles()))
67+
File inputFolderFile = inputFolder.toFile();
68+
List<File> files = Arrays.asList(Objects.requireNonNull(inputFolderFile.listFiles()));
69+
70+
for (File file : files) {
71+
if (file.getName().equals("WaypointData.dat")) {
72+
LOG.info("Found JourneyMap NBT waypoint data file: {}", file.getAbsolutePath());
73+
try {
74+
List<JMWaypointModern> jmWaypoints = readNbtWaypoints(file.toPath());
75+
return jmWaypoints.stream()
76+
.peek(wp -> LOG.info("Found {} JM waypoint: {} [{}, {}, {}]",
77+
"nbt",
78+
wp.getName(),
79+
wp.getX(),
80+
wp.getY(),
81+
wp.getZ()))
82+
.map(JourneyMapWaypointsToXaero::convertWaypoint)
83+
.collect(Collectors.toList());
84+
} catch (Exception e) {
85+
LOG.error("Error reading WaypointData.dat file: {}", file.getAbsolutePath(), e);
86+
throw new RuntimeException(e);
87+
}
88+
}
89+
}
90+
91+
return files.stream()
6492
.map(JourneyMapWaypointsToXaero::parseJourneyMapWaypointFile)
6593
.filter(Objects::nonNull)
6694
.peek(wp -> LOG.info("Found {} JM waypoint: {} [{}, {}, {}]",
@@ -140,4 +168,26 @@ public static XaeroWaypoint convertWaypoint(final IJMWaypoint jmWaypoint) {
140168
dimension
141169
);
142170
}
171+
172+
public static List<JMWaypointModern> readNbtWaypoints(Path nbtSrc) throws Exception {
173+
List<JMWaypointModern> waypoints = new ArrayList<>();
174+
CompoundTag tag = (CompoundTag) NBTIO.reader().named().read(nbtSrc, false);
175+
CompoundTag waypointsTag = tag.getCompoundTag("waypoints");
176+
for (Tag waypointTagEntry : waypointsTag.values()) {
177+
CompoundTag e = (CompoundTag) waypointTagEntry;
178+
String waypointName = e.getString("name");
179+
CompoundTag posTag = e.getCompoundTag("pos");
180+
int x = posTag.getInt("x");
181+
int y = posTag.getInt("y");
182+
int z = posTag.getInt("z");
183+
String dimension = posTag.getString("dimension");
184+
int color = e.getInt("color");
185+
int r = color >> 16 & 0xFF;
186+
int g = color >> 8 & 0xFF;
187+
int b = color & 0xFF;
188+
JMWaypointModern jmWaypointJsonModern = new JMWaypointModern(waypointName, x, y, z, r, g, b, true, new String[]{dimension});
189+
waypoints.add(jmWaypointJsonModern);
190+
}
191+
return waypoints;
192+
}
143193
}

0 commit comments

Comments
 (0)