From 0d326d973d356113031b063886d00444a309b1eb Mon Sep 17 00:00:00 2001 From: Thijs Wiefferink Date: Sun, 5 Aug 2018 12:23:32 +0200 Subject: [PATCH] Fix saving/restoring schematics with WorldEdit 7 --- .../areashop/handlers/WorldEditHandler7.java | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/WorldEdit 7/src/main/java/me/wiefferink/areashop/handlers/WorldEditHandler7.java b/WorldEdit 7/src/main/java/me/wiefferink/areashop/handlers/WorldEditHandler7.java index 893a9dd..5964a41 100644 --- a/WorldEdit 7/src/main/java/me/wiefferink/areashop/handlers/WorldEditHandler7.java +++ b/WorldEdit 7/src/main/java/me/wiefferink/areashop/handlers/WorldEditHandler7.java @@ -8,6 +8,7 @@ import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.bukkit.BukkitAdapter; 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.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; @@ -28,6 +29,7 @@ import me.wiefferink.areashop.interfaces.AreaShopInterface; import me.wiefferink.areashop.interfaces.GeneralRegionInterface; import me.wiefferink.areashop.interfaces.WorldEditInterface; import me.wiefferink.areashop.interfaces.WorldEditSelection; +import org.apache.commons.lang.exception.ExceptionUtils; import org.bukkit.entity.Player; import java.io.BufferedInputStream; @@ -124,8 +126,7 @@ public class WorldEditHandler7 extends WorldEditInterface { return false; } catch(IOException e) { pluginInterface.getLogger().warning("An error occured while restoring schematic of " + regionInterface.getName() + ", enable debug to see the complete stacktrace"); - // TODO enable - //pluginInterface.debugI(ExceptionUtils.getStackTrace(e)); + pluginInterface.debugI(ExceptionUtils.getStackTrace(e)); return false; } editSession.flushQueue(); @@ -158,17 +159,11 @@ public class WorldEditHandler7 extends WorldEditInterface { try(Closer closer = Closer.create()) { FileOutputStream fos = closer.register(new FileOutputStream(file)); BufferedOutputStream bos = closer.register(new BufferedOutputStream(fos)); - ClipboardFormat clipboardFormat = ClipboardFormats.findByAlias("schematic"); - if (clipboardFormat == null) { - pluginInterface.getLogger().warning("WorldEdit could not load default schematic format, try updating WorldEdit"); - return false; - } - ClipboardWriter writer = closer.register(clipboardFormat.getWriter(bos)); + ClipboardWriter writer = closer.register(BuiltInClipboardFormat.SPONGE_SCHEMATIC.getWriter(bos)); writer.write(clipboard); } catch(IOException e) { pluginInterface.getLogger().warning("An error occured while saving schematic of " + regionInterface.getName() + ", enable debug to see the complete stacktrace"); - // TODO enable - //pluginInterface.debugI(ExceptionUtils.getStackTrace(e)); + pluginInterface.debugI(ExceptionUtils.getStackTrace(e)); return false; } return true;