Fixes error with WorldEdit hook.

This commit is contained in:
tastybento 2019-07-04 13:56:52 -07:00
parent 349f339be3
commit cd4bea8a3e
2 changed files with 13 additions and 6 deletions

View File

@ -5,6 +5,7 @@ import com.google.common.collect.Sets;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; 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.ClipboardReader;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter; import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
import world.bentobox.bentobox.BentoBox; import world.bentobox.bentobox.BentoBox;
@ -24,6 +25,11 @@ import java.util.zip.ZipInputStream;
* @author CustomEntity * @author CustomEntity
*/ */
public class BlueprintClipboardFormat implements ClipboardFormat { public class BlueprintClipboardFormat implements ClipboardFormat {
public BlueprintClipboardFormat() {
ClipboardFormats.registerClipboardFormat(this);
}
@Override @Override
public String getName() { public String getName() {
return "Blueprint"; return "Blueprint";

View File

@ -1,9 +1,10 @@
package world.bentobox.bentobox.hooks; package world.bentobox.bentobox.hooks;
import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
import org.bukkit.Material; import org.bukkit.Material;
import org.eclipse.jdt.annotation.Nullable; import org.eclipse.jdt.annotation.Nullable;
import com.sk89q.worldedit.WorldEdit;
import world.bentobox.bentobox.api.hooks.Hook; import world.bentobox.bentobox.api.hooks.Hook;
import world.bentobox.bentobox.blueprints.worldedit.BlueprintClipboardFormat; import world.bentobox.bentobox.blueprints.worldedit.BlueprintClipboardFormat;
@ -14,7 +15,6 @@ import world.bentobox.bentobox.blueprints.worldedit.BlueprintClipboardFormat;
public class WorldEditHook extends Hook { public class WorldEditHook extends Hook {
private WorldEdit instance; private WorldEdit instance;
private BlueprintClipboardFormat clipboardFormat;
public WorldEditHook() { public WorldEditHook() {
super("WorldEdit", Material.WOODEN_AXE); super("WorldEdit", Material.WOODEN_AXE);
@ -22,15 +22,16 @@ public class WorldEditHook extends Hook {
@Override @Override
public boolean hook() { public boolean hook() {
try { try {
instance = WorldEdit.getInstance(); instance = WorldEdit.getInstance();
clipboardFormat = new BlueprintClipboardFormat(); new BlueprintClipboardFormat();
ClipboardFormats.registerClipboardFormat(clipboardFormat); } catch (Exception e) {
} catch (Exception | NoClassDefFoundError | NoSuchMethodError e) {
return false; return false;
} }
return instance != null; return instance != null;
} }
@Override @Override