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.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";

View File

@ -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