From 7eb7cd9b53f271f5eeb1196644ca14386412776d Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Tue, 11 Apr 2017 01:49:01 +1000 Subject: [PATCH] Ensure world loading occurs on the main thread --- .../plot/object/worlds/SinglePlotArea.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/worlds/SinglePlotArea.java b/Core/src/main/java/com/intellectualcrafters/plot/object/worlds/SinglePlotArea.java index afefdefa7..f378dd9cf 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/worlds/SinglePlotArea.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/worlds/SinglePlotArea.java @@ -9,8 +9,10 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotLoc; import com.intellectualcrafters.plot.object.PlotSettings; +import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.util.SetupUtils; +import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.WorldUtil; public class SinglePlotArea extends GridPlotWorld { @@ -30,17 +32,22 @@ public class SinglePlotArea extends GridPlotWorld { VOID = config.getBoolean("void", false); } - public void loadWorld(PlotId id) { - String worldName = id.toCommaSeparatedString(); - if (WorldUtil.IMP.isWorld(worldName)) return; - SetupObject setup = new SetupObject(); - setup.plotManager = "PlotSquared:single"; - setup.setupGenerator = "PlotSquared:single"; - setup.type = 0; - setup.terrain = 0; - setup.step = new ConfigurationNode[0]; - setup.world = worldName; - SetupUtils.manager.setupWorld(setup); + public void loadWorld(final PlotId id) { + TaskManager.IMP.sync(new RunnableVal() { + @Override + public void run(Object value) { + String worldName = id.toCommaSeparatedString(); + if (WorldUtil.IMP.isWorld(worldName)) return; + SetupObject setup = new SetupObject(); + setup.plotManager = "PlotSquared:single"; + setup.setupGenerator = "PlotSquared:single"; + setup.type = 0; + setup.terrain = 0; + setup.step = new ConfigurationNode[0]; + setup.world = worldName; + SetupUtils.manager.setupWorld(setup); + } + }); // String worldName = plot.getWorldName(); // World world = Bukkit.getWorld(worldName); // if (world != null) {