From d1478cf14894fc035a15ead9af19991d82d65866 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Sun, 2 Jul 2023 09:41:16 +0200 Subject: [PATCH 1/2] Change Schematic Reader and Write to FaWe --- .../src/de/steamwar/core/WorldEditWrapper14.java | 9 +++------ SpigotCore_18/build.gradle | 2 +- .../src/de/steamwar/core/WorldEditWrapper18.java | 8 +++----- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java b/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java index f23e7fc..746da57 100644 --- a/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java +++ b/SpigotCore_14/src/de/steamwar/core/WorldEditWrapper14.java @@ -13,10 +13,7 @@ import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Platform; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; -import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; -import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; -import com.sk89q.worldedit.extent.clipboard.io.NBTSchematicReader; +import com.sk89q.worldedit.extent.clipboard.io.*; import com.sk89q.worldedit.extent.clipboard.io.legacycompat.*; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.CuboidRegion; @@ -38,8 +35,8 @@ import static com.google.common.base.Preconditions.checkNotNull; public class WorldEditWrapper14 implements WorldEditWrapper.IWorldEditWrapper { - private static final ClipboardFormat SCHEMATIC = BuiltInClipboardFormat.MCEDIT_SCHEMATIC; - private static final ClipboardFormat SCHEM = BuiltInClipboardFormat.SPONGE_SCHEMATIC; + private static final ClipboardFormat SCHEMATIC = ClipboardFormats.findByAlias("schematic"); + private static final ClipboardFormat SCHEM = ClipboardFormats.findByAlias("schem"); @Override public InputStream getPlayerClipboard(Player player, boolean schemFormat) { diff --git a/SpigotCore_18/build.gradle b/SpigotCore_18/build.gradle index ea1260c..8cc8152 100644 --- a/SpigotCore_18/build.gradle +++ b/SpigotCore_18/build.gradle @@ -47,7 +47,7 @@ dependencies { compileOnly project(":SpigotCore_14") compileOnly project(':CommonCore') - compileOnly swdep("WorldEdit-1.15") + compileOnly swdep("FastAsyncWorldEdit-1.18") compileOnly 'org.spigotmc:spigot-api:1.18-R0.1-SNAPSHOT' compileOnly 'com.mojang:datafixerupper:4.0.26' diff --git a/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java b/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java index a3a12fc..7d35d82 100644 --- a/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java +++ b/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java @@ -19,10 +19,8 @@ package de.steamwar.core; -import com.sk89q.jnbt.NBTInputStream; import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader; -import com.sk89q.worldedit.extent.clipboard.io.SpongeSchematicReader; +import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; import de.steamwar.sql.NoClipboardException; import java.io.IOException; @@ -35,9 +33,9 @@ public class WorldEditWrapper18 extends WorldEditWrapper14 { //Use FAWE reader due to FAWE capability of reading corrupt FAWE schems try { if(schemFormat){ - return new SpongeSchematicReader(new NBTInputStream(is)).read(); + return BuiltInClipboardFormat.FAST.load(is); }else{ - return new MCEditSchematicReader(new NBTInputStream(is)).read(); + return BuiltInClipboardFormat.MCEDIT_SCHEMATIC.load(is); } } catch (NullPointerException e) { throw new NoClipboardException(); -- 2.39.2 From 11396cc69c7b46123e03c851d94fd01d02ecfdd1 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Wed, 30 Aug 2023 12:39:19 +0200 Subject: [PATCH 2/2] Fix double GZIP decompression --- .../src/de/steamwar/core/WorldEditWrapper18.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java b/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java index 7d35d82..f9aa869 100644 --- a/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java +++ b/SpigotCore_18/src/de/steamwar/core/WorldEditWrapper18.java @@ -19,8 +19,10 @@ package de.steamwar.core; +import com.fastasyncworldedit.core.extent.clipboard.io.FastSchematicReader; +import com.sk89q.jnbt.NBTInputStream; import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.extent.clipboard.io.BuiltInClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.MCEditSchematicReader; import de.steamwar.sql.NoClipboardException; import java.io.IOException; @@ -29,14 +31,12 @@ import java.io.InputStream; public class WorldEditWrapper18 extends WorldEditWrapper14 { @Override + @SuppressWarnings("removal") public Clipboard getClipboard(InputStream is, boolean schemFormat) throws IOException { //Use FAWE reader due to FAWE capability of reading corrupt FAWE schems + NBTInputStream nbtStream = new NBTInputStream(is); try { - if(schemFormat){ - return BuiltInClipboardFormat.FAST.load(is); - }else{ - return BuiltInClipboardFormat.MCEDIT_SCHEMATIC.load(is); - } + return (schemFormat ? new FastSchematicReader(nbtStream) : new MCEditSchematicReader(nbtStream)).read(); } catch (NullPointerException e) { throw new NoClipboardException(); } -- 2.39.2