From cd4bea8a3efb775837581800b0b8fd4bfa25b206 Mon Sep 17 00:00:00 2001 From: tastybento Date: Thu, 4 Jul 2019 13:56:52 -0700 Subject: [PATCH] Fixes error with WorldEdit hook. --- .../worldedit/BlueprintClipboardFormat.java | 6 ++++++ .../bentobox/bentobox/hooks/WorldEditHook.java | 13 +++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/java/world/bentobox/bentobox/blueprints/worldedit/BlueprintClipboardFormat.java b/src/main/java/world/bentobox/bentobox/blueprints/worldedit/BlueprintClipboardFormat.java index ded9f9820..fd58cf739 100644 --- a/src/main/java/world/bentobox/bentobox/blueprints/worldedit/BlueprintClipboardFormat.java +++ b/src/main/java/world/bentobox/bentobox/blueprints/worldedit/BlueprintClipboardFormat.java @@ -5,6 +5,7 @@ import com.google.common.collect.Sets; import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; +import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; import world.bentobox.bentobox.BentoBox; @@ -24,6 +25,11 @@ import java.util.zip.ZipInputStream; * @author CustomEntity */ public class BlueprintClipboardFormat implements ClipboardFormat { + + public BlueprintClipboardFormat() { + ClipboardFormats.registerClipboardFormat(this); + } + @Override public String getName() { return "Blueprint"; diff --git a/src/main/java/world/bentobox/bentobox/hooks/WorldEditHook.java b/src/main/java/world/bentobox/bentobox/hooks/WorldEditHook.java index 7f2783ae8..c82c5d347 100644 --- a/src/main/java/world/bentobox/bentobox/hooks/WorldEditHook.java +++ b/src/main/java/world/bentobox/bentobox/hooks/WorldEditHook.java @@ -1,9 +1,10 @@ package world.bentobox.bentobox.hooks; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import org.bukkit.Material; import org.eclipse.jdt.annotation.Nullable; + +import com.sk89q.worldedit.WorldEdit; + import world.bentobox.bentobox.api.hooks.Hook; import world.bentobox.bentobox.blueprints.worldedit.BlueprintClipboardFormat; @@ -14,7 +15,6 @@ import world.bentobox.bentobox.blueprints.worldedit.BlueprintClipboardFormat; public class WorldEditHook extends Hook { private WorldEdit instance; - private BlueprintClipboardFormat clipboardFormat; public WorldEditHook() { super("WorldEdit", Material.WOODEN_AXE); @@ -22,15 +22,16 @@ public class WorldEditHook extends Hook { @Override public boolean hook() { + try { instance = WorldEdit.getInstance(); - clipboardFormat = new BlueprintClipboardFormat(); - ClipboardFormats.registerClipboardFormat(clipboardFormat); - } catch (Exception | NoClassDefFoundError | NoSuchMethodError e) { + new BlueprintClipboardFormat(); + } catch (Exception e) { return false; } return instance != null; + } @Override