From dbbb450172e001f656900acf01be34668dfccb60 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sat, 18 Sep 2021 03:19:49 +0100 Subject: [PATCH] Flush clipboards before writing schematics. #1286 --- .../core/extent/clipboard/io/FastSchematicWriter.java | 1 + .../extent/clipboard/io/schematic/MinecraftStructure.java | 1 + .../core/extent/clipboard/io/schematic/PNGWriter.java | 1 + .../worldedit/extent/clipboard/io/SpongeSchematicWriter.java | 4 ++++ 4 files changed, 7 insertions(+) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicWriter.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicWriter.java index 6337535cf..f5861e4d1 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicWriter.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/FastSchematicWriter.java @@ -72,6 +72,7 @@ public class FastSchematicWriter implements ClipboardWriter { @Override public void write(Clipboard clipboard) throws IOException { + clipboard.flush(); // For now always write the latest version. Maybe provide support for earlier if more appear. write2(clipboard); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java index c7d5d96a0..600ccf50b 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/MinecraftStructure.java @@ -153,6 +153,7 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter { @Override public void write(Clipboard clipboard) throws IOException { + clipboard.flush(); write(clipboard, "FAWE"); } diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/PNGWriter.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/PNGWriter.java index a2e5b1798..b4812e2e8 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/PNGWriter.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/clipboard/io/schematic/PNGWriter.java @@ -31,6 +31,7 @@ public class PNGWriter implements ClipboardWriter { @Override public void write(Clipboard clipboard) throws IOException { + clipboard.flush(); Region region = clipboard.getRegion(); int width = region.getWidth(); int height = region.getHeight(); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java index 47e3cb7f2..55198d12c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicWriter.java @@ -78,6 +78,10 @@ public class SpongeSchematicWriter implements ClipboardWriter { @Override public void write(Clipboard clipboard) throws IOException { + //FAWE start - ensure clipboard is flushed in case of using clipboard-on-disk. Maintains allowing of the same code + // between upstream and FAWE + clipboard.flush(); + //FAWE end // For now always write the latest version. Maybe provide support for earlier if more appear. outputStream.writeNamedTag("Schematic", new CompoundTag(write2(clipboard))); }