Skip to content

Commit 771d20a

Browse files
committed
Fixed Output Filename
1 parent d45fef8 commit 771d20a

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ This has now been implemented by upstream. They have unified both End City Ships
7979
![Elytra](https://i.imgur.com/fFxoFX4.png)
8080

8181
### Export SeedMap
82-
- Added **Export JSON** button on the top right of the SeedMap screen which will export all selected locations to a JSON
82+
- Added **Export JSON** button on the top right of the SeedMap screen which will export all selected locations to a JSON in the folder ```SeedMapper/exports/<Server IP>_<Seed>-<Date/Time>.json```.
8383
- Added **Export Xaero** button on the top right of the SeedMap screen which will export all selected locations into Xaero World Map waypoints for the server you're in. Disconnect from the server you're in and reconnect and the waypoints will appear in Xaero.
8484

8585
### Improved ESP
@@ -97,5 +97,10 @@ Can now finally remove SeedMapper waypoints with via a right click context menu.
9797
![Map](https://i.imgur.com/1qDgQw7.png)
9898

9999
### Highlight Timeout Setting
100-
101100
Can now change the default 5 minute render timeout with ```/sm:config esptimeout```
101+
102+
### Export Loot Table
103+
Can now export the entire loot table for the map you're viewing by clicking ```Export Loot``` or via commands such as ```/sm:exportLoot <radius> [dimension] [structures/all]```.
104+
105+
Exported data will be located in ```SeedMapper/loot/<Server IP>_<Seed>-<Date/Time>.json```
106+

src/main/java/dev/xpple/seedmapper/seedmap/SeedMapScreen.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,33 @@ private void exportVisibleStructures() {
11181118
try {
11191119
Files.createDirectories(exportDir);
11201120
String timestamp = EXPORT_TIMESTAMP.format(LocalDateTime.now());
1121-
Path exportFile = exportDir.resolve("structures-%d-%d-%s.json".formatted(this.seed, this.dimension, timestamp));
1121+
1122+
// build server id same as loot exporter
1123+
String serverId = "local";
1124+
try {
1125+
if (this.minecraft.getConnection() != null && this.minecraft.getConnection().getConnection() != null) {
1126+
java.net.SocketAddress remote = this.minecraft.getConnection().getConnection().getRemoteAddress();
1127+
if (remote instanceof java.net.InetSocketAddress inet) {
1128+
java.net.InetAddress addr = inet.getAddress();
1129+
if (addr != null) {
1130+
serverId = addr.getHostAddress() + "_" + inet.getPort();
1131+
} else {
1132+
serverId = inet.getHostString() + "_" + inet.getPort();
1133+
}
1134+
} else if (remote != null) {
1135+
serverId = remote.toString();
1136+
}
1137+
}
1138+
} catch (Exception ignored) {
1139+
serverId = "local";
1140+
}
1141+
serverId = serverId.replaceAll("[^A-Za-z0-9._-]", "_");
1142+
serverId = serverId.replaceAll("_+", "_");
1143+
serverId = serverId.replaceAll("^[-_]+|[-_]+$", "");
1144+
if (serverId.isBlank()) serverId = "local";
1145+
1146+
String seedStr = Long.toString(this.seed);
1147+
Path exportFile = exportDir.resolve("%s_%s-%s.json".formatted(serverId, seedStr, timestamp));
11221148
Files.writeString(exportFile, GSON.toJson(array), StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING, StandardOpenOption.WRITE);
11231149
player.displayClientMessage(Component.literal("Exported %d entries to %s".formatted(array.size(), exportFile.toAbsolutePath())), false);
11241150
} catch (IOException e) {

0 commit comments

Comments
 (0)