diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java index 24551aadb..103bf21fc 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java @@ -74,16 +74,13 @@ public class BukkitChunkManager extends ChunkManager { int sx = pos1.getX() << 4; int sz = pos1.getZ() << 4; - String worldName1 = world1.getName(); - String worldName2 = world2.getName(); - BukkitWorld bukkitWorld1 = new BukkitWorld(world1); BukkitWorld bukkitWorld2 = new BukkitWorld(world2); QueueCoordinator queue1 = - PlotSquared.platform().getGlobalBlockQueue().getNewQueue(worldName1, false); + PlotSquared.platform().getGlobalBlockQueue().getNewQueue(bukkitWorld1, false); QueueCoordinator queue2 = - PlotSquared.platform().getGlobalBlockQueue().getNewQueue(worldName2, false); + PlotSquared.platform().getGlobalBlockQueue().getNewQueue(bukkitWorld2, false); for (int x = Math.max(r1.getMinimumPoint().getX(), sx); x <= Math.min(r1.getMaximumPoint().getX(), sx + 15); x++) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java index 6b6491a9d..c078fe174 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitRegionManager.java @@ -41,6 +41,7 @@ import com.plotsquared.core.util.ChunkManager; import com.plotsquared.core.util.MainUtil; import com.plotsquared.core.util.RegionManager; import com.plotsquared.core.util.RegionUtil; +import com.plotsquared.core.util.WorldUtil; import com.plotsquared.core.util.entity.EntityCategories; import com.plotsquared.core.util.task.RunnableVal; import com.plotsquared.core.util.task.TaskManager; @@ -84,9 +85,12 @@ public class BukkitRegionManager extends RegionManager { private static final Logger logger = LoggerFactory.getLogger("P2/" + BukkitRegionManager.class.getSimpleName()); + private final WorldUtil worldUtil; - @Inject public BukkitRegionManager(@Nonnull final ChunkManager chunkManager) { - super(chunkManager); + @Inject public BukkitRegionManager(@Nonnull final ChunkManager chunkManager, + @Nonnull final WorldUtil worldUtil) { + super(chunkManager, worldUtil); + this.worldUtil = worldUtil; } public static boolean isIn(CuboidRegion region, int x, int z) { @@ -210,15 +214,11 @@ public class BukkitRegionManager extends RegionManager { final CuboidRegion region = RegionUtil.createRegion(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); - final World oldWorld = Bukkit.getWorld(pos1.getWorldName()); - final BukkitWorld oldBukkitWorld = new BukkitWorld(oldWorld); - final World newWorld = Bukkit.getWorld(newPos.getWorldName()); - assert newWorld != null; - assert oldWorld != null; - final String newWorldName = newWorld.getName(); + final BukkitWorld oldWorld = new BukkitWorld((World) pos1.getWorld()); + final BukkitWorld newWorld = new BukkitWorld((World) newPos.getWorld()); final ContentMap map = new ContentMap(); final QueueCoordinator queue = - PlotSquared.platform().getGlobalBlockQueue().getNewQueue(newWorldName, false); + PlotSquared.platform().getGlobalBlockQueue().getNewQueue(newWorld, false); ChunkManager.chunkTask(pos1, pos2, new RunnableVal() { @Override public void run(int[] value) { int bx = value[2]; @@ -232,7 +232,7 @@ public class BukkitRegionManager extends RegionManager { .thenAccept(chunk1 -> map.saveEntitiesIn(chunk1, region)).thenRun(() -> { for (int x = bx & 15; x <= (tx & 15); x++) { for (int z = bz & 15; z <= (tz & 15); z++) { - map.saveBlocks(oldBukkitWorld, 256, cxx + x, czz + z, relX, relZ); + map.saveBlocks(oldWorld, 256, cxx + x, czz + z, relX, relZ); } } }); @@ -250,7 +250,7 @@ public class BukkitRegionManager extends RegionManager { } queue.setCompleteTask(() -> { //map.restoreBlocks(newWorld, 0, 0); - map.restoreEntities(newWorld, relX, relZ); + map.restoreEntities((World) newPos.getWorld(), relX, relZ); TaskManager.runTask(whenDone); }); queue.enqueue(); diff --git a/Core/src/main/java/com/plotsquared/core/command/Trim.java b/Core/src/main/java/com/plotsquared/core/command/Trim.java index 4e2ec2a08..b40d6f03d 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Trim.java +++ b/Core/src/main/java/com/plotsquared/core/command/Trim.java @@ -190,7 +190,7 @@ public class Trim extends SubCommand { } } } - final QueueCoordinator queue = blockQueue.getNewQueue(world, false); + final QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world), false); TaskManager.getPlatformImplementation().objectTask(chunks, new RunnableVal() { @Override public void run(BlockVector2 value) { queue.regenChunk(value.getX(), value.getZ()); diff --git a/Core/src/main/java/com/plotsquared/core/generator/AugmentedUtils.java b/Core/src/main/java/com/plotsquared/core/generator/AugmentedUtils.java index b40e718af..16ded7334 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/AugmentedUtils.java +++ b/Core/src/main/java/com/plotsquared/core/generator/AugmentedUtils.java @@ -87,7 +87,7 @@ public class AugmentedUtils { IndependentPlotGenerator generator = area.getGenerator(); // Mask if (queue == null) { - queue = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(world, false); + queue = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(world), false); queue.setChunkObject(chunkObject); } QueueCoordinator primaryMask; diff --git a/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java b/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java index 016a547ea..ef20a88b6 100644 --- a/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java +++ b/Core/src/main/java/com/plotsquared/core/generator/HybridUtils.java @@ -128,7 +128,7 @@ public class HybridUtils { * */ TaskManager.runTaskAsync(() -> { - final QueueCoordinator queue = blockQueue.getNewQueue(world, false); + final QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world), false); final BlockVector3 bot = region.getMinimumPoint(); final BlockVector3 top = region.getMaximumPoint(); @@ -520,7 +520,7 @@ public class HybridUtils { public boolean setupRoadSchematic(Plot plot) { final String world = plot.getWorldName(); - final QueueCoordinator queue = blockQueue.getNewQueue(world, false); + final QueueCoordinator queue = blockQueue.getNewQueue(worldUtil.getWeWorld(world), false); Location bot = plot.getBottomAbs().subtract(1, 0, 1); Location top = plot.getTopAbs(); final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea(); @@ -607,7 +607,7 @@ public class HybridUtils { z -= plotWorld.ROAD_OFFSET_Z; final int finalX = x; final int finalZ = z; - QueueCoordinator queue = this.blockQueue.getNewQueue(plotWorld.getWorldName(), false); + QueueCoordinator queue = this.blockQueue.getNewQueue(worldUtil.getWeWorld(plotWorld.getWorldName()), false); if (id1 == null || id2 == null || id1 != id2) { this.chunkManager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> { if (id1 != null) { diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index f661f6a29..827aa2c70 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -1687,7 +1687,7 @@ public class Plot { * This should not need to be called */ public void refreshChunks() { - QueueCoordinator queue = this.blockQueue.getNewQueue(getWorldName(), false); + QueueCoordinator queue = this.blockQueue.getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(getWorldName()), false); HashSet chunks = new HashSet<>(); for (CuboidRegion region : Plot.this.getRegions()) { for (int x = region.getMinimumPoint().getX() >> 4; diff --git a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java index 4aecc38d9..ab49691ca 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java +++ b/Core/src/main/java/com/plotsquared/core/plot/PlotArea.java @@ -27,6 +27,7 @@ package com.plotsquared.core.plot; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; +import com.plotsquared.core.PlotSquared; import com.plotsquared.core.collection.QuadMap; import com.plotsquared.core.configuration.CaptionUtility; import com.plotsquared.core.configuration.Captions; @@ -172,7 +173,7 @@ public abstract class PlotArea { @Nonnull protected abstract PlotManager createManager(); public QueueCoordinator getQueue(final boolean autoQueue) { - return this.globalBlockQueue.getNewQueue(worldName, autoQueue); + return this.globalBlockQueue.getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(worldName), autoQueue); } /** diff --git a/Core/src/main/java/com/plotsquared/core/queue/GlobalBlockQueue.java b/Core/src/main/java/com/plotsquared/core/queue/GlobalBlockQueue.java index eb40df5b0..56437f0cd 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/GlobalBlockQueue.java +++ b/Core/src/main/java/com/plotsquared/core/queue/GlobalBlockQueue.java @@ -26,13 +26,9 @@ package com.plotsquared.core.queue; import com.plotsquared.core.PlotSquared; -<<<<<<< HEAD +import com.sk89q.worldedit.world.World; import lombok.Getter; import lombok.Setter; -======= -import com.plotsquared.core.util.task.RunnableVal2; -import com.plotsquared.core.util.task.TaskManager; -import com.plotsquared.core.util.task.TaskTime; import java.util.ArrayList; import java.util.List; @@ -48,7 +44,7 @@ public class GlobalBlockQueue { this.activeQueues = new ConcurrentLinkedDeque<>(); } - public QueueCoordinator getNewQueue(String world, boolean autoQueue) { + public QueueCoordinator getNewQueue(World world, boolean autoQueue) { QueueCoordinator queue = provider.getNewQueue(world); // Auto-inject into the queue PlotSquared.platform().getInjector().injectMembers(queue); diff --git a/Core/src/main/java/com/plotsquared/core/queue/QueueProvider.java b/Core/src/main/java/com/plotsquared/core/queue/QueueProvider.java index 207b29ee0..27c6a6866 100644 --- a/Core/src/main/java/com/plotsquared/core/queue/QueueProvider.java +++ b/Core/src/main/java/com/plotsquared/core/queue/QueueProvider.java @@ -25,6 +25,8 @@ */ package com.plotsquared.core.queue; +import com.sk89q.worldedit.world.World; + public abstract class QueueProvider { public static QueueProvider of(final Class primary, final Class fallback) { @@ -32,7 +34,7 @@ public abstract class QueueProvider { private boolean failed = false; - @Override public QueueCoordinator getNewQueue(String world) { + @Override public QueueCoordinator getNewQueue(World world) { if (!failed) { try { return (QueueCoordinator) primary.getConstructors()[0].newInstance(world); @@ -51,5 +53,5 @@ public abstract class QueueProvider { }; } - public abstract QueueCoordinator getNewQueue(String world); + public abstract QueueCoordinator getNewQueue(World world); } diff --git a/Core/src/main/java/com/plotsquared/core/util/ChunkManager.java b/Core/src/main/java/com/plotsquared/core/util/ChunkManager.java index dce0f43ed..0a7bc6ccd 100644 --- a/Core/src/main/java/com/plotsquared/core/util/ChunkManager.java +++ b/Core/src/main/java/com/plotsquared/core/util/ChunkManager.java @@ -51,7 +51,7 @@ public abstract class ChunkManager { public static void setChunkInPlotArea(RunnableVal force, RunnableVal add, String world, BlockVector2 loc) { QueueCoordinator queue = - PlotSquared.platform().getGlobalBlockQueue().getNewQueue(world, false); + PlotSquared.platform().getGlobalBlockQueue().getNewQueue(PlotSquared.platform().getWorldUtil().getWeWorld(world), false); if (PlotSquared.get().getPlotAreaManager().isAugmented(world) && PlotSquared.get() .isNonStandardGeneration(world, loc)) { int blockX = loc.getX() << 4; diff --git a/Core/src/main/java/com/plotsquared/core/util/RegionManager.java b/Core/src/main/java/com/plotsquared/core/util/RegionManager.java index bcf5fb58d..9b9bd9a7d 100644 --- a/Core/src/main/java/com/plotsquared/core/util/RegionManager.java +++ b/Core/src/main/java/com/plotsquared/core/util/RegionManager.java @@ -55,7 +55,7 @@ public abstract class RegionManager { public static RegionManager manager = null; private final ChunkManager chunkManager; - public RegionManager(@Nonnull final ChunkManager chunkManager) { + public RegionManager(@Nonnull final ChunkManager chunkManager, @Nonnull WorldUtil worldUtil) { this.chunkManager = chunkManager; }