mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Start switching to WorldEdit Worlds
This commit is contained in:
parent
74c6fc954e
commit
66b94ab9f1
@ -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++) {
|
||||
|
@ -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<int[]>() {
|
||||
@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();
|
||||
|
@ -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<BlockVector2>() {
|
||||
@Override public void run(BlockVector2 value) {
|
||||
queue.regenChunk(value.getX(), value.getZ());
|
||||
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
@ -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<BlockVector2> chunks = new HashSet<>();
|
||||
for (CuboidRegion region : Plot.this.getRegions()) {
|
||||
for (int x = region.getMinimumPoint().getX() >> 4;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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);
|
||||
|
@ -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<? extends QueueCoordinator> primary,
|
||||
final Class<? extends QueueCoordinator> 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);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public abstract class ChunkManager {
|
||||
public static void setChunkInPlotArea(RunnableVal<ScopedQueueCoordinator> force,
|
||||
RunnableVal<ScopedQueueCoordinator> 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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user