From afb0a9f17f49b80f1370d981959ea3c027f364ae Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Tue, 25 Dec 2018 12:05:01 +0100 Subject: [PATCH] Forcefully load WorldEdit on startup --- .../plotsquared/bukkit/BukkitMain.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java index ed5884990..0023a6b0f 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/BukkitMain.java @@ -29,10 +29,12 @@ import com.github.intellectualsites.plotsquared.plot.util.*; import com.github.intellectualsites.plotsquared.plot.util.block.QueueProvider; import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper; import com.sk89q.worldedit.WorldEdit; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import com.sk89q.worldedit.extension.platform.Capability; import lombok.Getter; import lombok.NonNull; -import org.bukkit.*; import org.bukkit.Location; +import org.bukkit.*; import org.bukkit.command.PluginCommand; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; @@ -103,8 +105,19 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain } } catch (Throwable ignore) { } + // Force WorldEdit to load + try { + System.out.println("[P2] Force loading WorldEdit"); + if (!manager.isPluginEnabled("WorldEdit")) { + manager.enablePlugin(WorldEditPlugin.getPlugin(WorldEditPlugin.class)); + } + System.out.println("[P2] Testing platform capabilities"); + WorldEdit.getInstance().getPlatformManager().queryCapability(Capability.GAME_HOOKS); + } catch (final Throwable throwable) { + throw new IllegalStateException("Failed to force load WorldEdit." + + " Road schematics will fail to generate", throwable); + } } - private final LegacyMappings legacyMappings = new BukkitLegacyMappings(); private final BlockRegistry blockRegistry = new BukkitBlockRegistry(Material.values());