-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add the dump command #19
base: 1.19.4
Are you sure you want to change the base?
Conversation
} | ||
} | ||
|
||
private static Path getAndCheckDataPath(Path path, Identifier identifier, String extension) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, we should probably apply this to the map template exporter, too 😅
var path = getAndCheckDataPath(generatedPath, identifier, FILE_EXTENSION); | ||
|
||
var json = NbtOps.INSTANCE.convertTo(JsonOps.INSTANCE, nbt); | ||
System.out.println(json); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be removed?
} | ||
|
||
public static CompletableFuture<Void> saveToExport(MinecraftServer server, NbtCompound nbt, Identifier identifier) { | ||
return CompletableFuture.supplyAsync(() -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: CompletableFuture.runAsync(() -> {})
try (var output = Files.newOutputStream(path)) { | ||
var jsonWriter = new JsonWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try (var output = Files.newOutputStream(path)) { | |
var jsonWriter = new JsonWriter(new OutputStreamWriter(output, StandardCharsets.UTF_8)); | |
try (var writer = new JsonWriter(Files.newBufferedWriter(path, StandardCharsets.UTF_8)) { |
jsonWriter.setIndent(" "); | ||
|
||
JsonHelper.writeSorted(jsonWriter, json, DataProvider.JSON_KEY_SORTING_COMPARATOR); | ||
jsonWriter.flush(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should not be needed if including the JsonWriter
in the try-with-resources
|
||
var future = DumpExporter.saveToExport(source.getServer(), nbt, identifier); | ||
|
||
future.handle((v, throwable) -> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whenCompleteAsync(..., server)
? Sending messages off-thread has potential to explode 😅
This pull request adds a command that can be used to export entity, block entity, or command storage NBT to a file.
For example:
/dump entity 2a99a580-41d7-4c93-aa87-abd90664ff52 armor_stand
/dump block 18 -60 20 chest
/dump storage taters nucleoid:tater_box