From 86394140e63829c7e18801477254445cf875b011 Mon Sep 17 00:00:00 2001 From: Esophose Date: Fri, 19 Jul 2019 23:15:29 -0600 Subject: [PATCH] FAWE support for pasting worldedit schematics --- build.gradle | 3 --- .../java/me/goodandevil/skyblock/listeners/Entity.java | 3 ++- .../skyblock/utils/structure/SchematicUtil.java | 10 ++++++++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index ef707d3b..a38ca4e5 100644 --- a/build.gradle +++ b/build.gradle @@ -50,9 +50,6 @@ dependencies { shade (group: 'org.apache.commons', name: 'commons-lang3', version: '3.0') shade (group: 'commons-io', name: 'commons-io', version: '2.5') - // JetBrains Annotations - compile (group: 'org.jetbrains', name: 'annotations', version: '13.0') - // Songoda Updater shade (group: 'com.songoda', name: 'songodaupdater', version: '1') diff --git a/src/main/java/me/goodandevil/skyblock/listeners/Entity.java b/src/main/java/me/goodandevil/skyblock/listeners/Entity.java index 82d8265e..6738ff14 100644 --- a/src/main/java/me/goodandevil/skyblock/listeners/Entity.java +++ b/src/main/java/me/goodandevil/skyblock/listeners/Entity.java @@ -656,7 +656,8 @@ public class Entity implements Listener { @EventHandler public void onCreatureSpawn(CreatureSpawnEvent event) { - if (event.getEntity() instanceof ArmorStand || event.getEntity() instanceof FallingBlock + if (event.getEntity() instanceof ArmorStand + || event.getEntity() instanceof FallingBlock || event.getEntity() instanceof org.bukkit.entity.Item) { return; } diff --git a/src/main/java/me/goodandevil/skyblock/utils/structure/SchematicUtil.java b/src/main/java/me/goodandevil/skyblock/utils/structure/SchematicUtil.java index 2947377c..3f40ad8c 100644 --- a/src/main/java/me/goodandevil/skyblock/utils/structure/SchematicUtil.java +++ b/src/main/java/me/goodandevil/skyblock/utils/structure/SchematicUtil.java @@ -17,7 +17,7 @@ public class SchematicUtil { if (!Bukkit.getPluginManager().isPluginEnabled("WorldEdit")) throw new IllegalStateException("Tried to generate an island using a schematic file without WorldEdit installed!"); - Bukkit.getScheduler().runTask(SkyBlock.getInstance(), () -> { + Runnable pasteTask = () -> { if (NMSUtil.getVersionNumber() > 12) { // WorldEdit 7 com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat format = com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats.findByFile(schematicFile); try (com.sk89q.worldedit.extent.clipboard.io.ClipboardReader reader = format.getReader(new FileInputStream(schematicFile))) { @@ -59,7 +59,13 @@ public class SchematicUtil { e.printStackTrace(); } } - }); + }; + + if (Bukkit.getPluginManager().isPluginEnabled("FastAsyncWorldEdit")) { + Bukkit.getScheduler().runTaskAsynchronously(SkyBlock.getInstance(), pasteTask); + } else { + Bukkit.getScheduler().runTask(SkyBlock.getInstance(), pasteTask); + } return new Float[] { location.getYaw(), location.getPitch() }; }