From 5d31b7034d4f24e95689b3af4ff1d0d7d27c9835 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sun, 12 Sep 2021 15:57:52 +0100 Subject: [PATCH] Deprecate sponge schematic reader/writer and tell users why (#1287) --- .../plotsquared/FaweDelegateSchematicHandler.java | 2 +- .../extent/clipboard/io/BuiltInClipboardFormat.java | 10 ++++++++-- .../extent/clipboard/io/SpongeSchematicReader.java | 5 +++++ .../extent/clipboard/io/SpongeSchematicWriter.java | 5 +++++ 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java index f51a2794b..fd682ef12 100644 --- a/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java +++ b/worldedit-bukkit/src/main/java/com/fastasyncworldedit/bukkit/regions/plotsquared/FaweDelegateSchematicHandler.java @@ -177,7 +177,7 @@ public class FaweDelegateSchematicHandler { public void run(OutputStream output) { if (weTag instanceof CompressedSchematicTag) { Clipboard clipboard = ((CompressedSchematicTag) weTag).getSource(); - BuiltInClipboardFormat.SPONGE_SCHEMATIC.write(output, clipboard); + BuiltInClipboardFormat.FAST.write(output, clipboard); } try { try (ParallelGZIPOutputStream gzip = new ParallelGZIPOutputStream(output)) { diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java index 7c4c0d37d..0f73e67ee 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/BuiltInClipboardFormat.java @@ -51,7 +51,7 @@ import java.util.zip.GZIPOutputStream; public enum BuiltInClipboardFormat implements ClipboardFormat { //FAWE start - register fast clipboard io - FAST("fast", "fawe") { + FAST("fast", "fawe", "sponge", "schem") { @Override public String getPrimaryFileExtension() { return "schem"; @@ -119,7 +119,13 @@ public enum BuiltInClipboardFormat implements ClipboardFormat { } }, - SPONGE_SCHEMATIC("sponge", "schem") { + /** + * @deprecated Slow, resource intensive, but sometimes safer than using the recommended + * {@link BuiltInClipboardFormat#FAST}. + * Avoid using with any large schematics/clipboards for reading/writing. + */ + @Deprecated + SPONGE_SCHEMATIC("slow", "safe") { @Override public String getPrimaryFileExtension() { return "schem"; diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java index e5eb9bfcf..787a5253b 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extent/clipboard/io/SpongeSchematicReader.java @@ -68,7 +68,12 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Reads schematic files using the Sponge Schematic Specification. + * + * @deprecated Slow, resource intensive, but sometimes safer than using the recommended + * {@link com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReader}. + * Avoid reading large schematics with this reader. */ +@Deprecated public class SpongeSchematicReader extends NBTSchematicReader { private static final Logger LOGGER = LogManagerCompat.getLogger(); 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 8f4a7fa80..47e3cb7f2 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 @@ -53,7 +53,12 @@ import static com.google.common.base.Preconditions.checkNotNull; /** * Writes schematic files using the Sponge schematic format. + * + * @deprecated Slow, resource intensive, but sometimes safer than using the recommended + * {@link com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicWriter}. + * Avoid using large clipboards to create schematics with this writer. */ +@Deprecated public class SpongeSchematicWriter implements ClipboardWriter { private static final int CURRENT_VERSION = 2;