mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 12:35:15 +01:00
Finish cross world plot moving [UNTESTED]
This commit is contained in:
parent
844afb0183
commit
b4fab94192
@ -37,7 +37,6 @@ import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8;
|
||||
import com.intellectualcrafters.plot.listeners.PlotPlusListener;
|
||||
import com.intellectualcrafters.plot.listeners.WorldEditListener;
|
||||
import com.intellectualcrafters.plot.listeners.WorldEvents;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.titles.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.titles.DefaultTitle;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
|
@ -25,7 +25,6 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
@ -48,11 +47,9 @@ import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.PlotSquaredException;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitSetBlockManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.SetBlockFast;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
||||
|
||||
|
@ -98,7 +98,7 @@ public class Condense extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "NO PLOTS FOUND");
|
||||
return false;
|
||||
}
|
||||
MainUtil.move(worldname, to_move.get(0), free.get(0), new Runnable() {
|
||||
MainUtil.move(MainUtil.getPlot(worldname, to_move.get(0)), MainUtil.getPlot(worldname, free.get(0)), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!TASK) {
|
||||
@ -140,7 +140,7 @@ public class Condense extends SubCommand {
|
||||
return;
|
||||
}
|
||||
sendMessage("MOVING " + to_move.get(0) + " to " + free.get(0));
|
||||
MainUtil.move(worldname, to_move.get(0), free.get(0), this);
|
||||
MainUtil.move(MainUtil.getPlot(worldname, to_move.get(0)), MainUtil.getPlot(worldname, free.get(0)), this);
|
||||
}
|
||||
});
|
||||
TASK = true;
|
||||
|
@ -20,7 +20,6 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.commands.SubCommand.CommandCategory;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.CmdInstance;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
|
@ -27,7 +27,6 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
|
@ -34,7 +34,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
public class Inbox extends SubCommand {
|
||||
public Inbox() {
|
||||
|
@ -21,9 +21,7 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -20,11 +20,13 @@
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
|
||||
@ -55,18 +57,32 @@ public class Move extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
final String world = loc.getWorld();
|
||||
final PlotId plot2 = MainUtil.parseId(args[0]);
|
||||
if ((plot2 == null)) {
|
||||
final PlotId plot2id = MainUtil.parseId(args[0]);
|
||||
if ((plot2id == null)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move <X;Z>");
|
||||
return false;
|
||||
}
|
||||
if (plot1.id.equals(plot2)) {
|
||||
String world2;
|
||||
if (args.length == 2) {
|
||||
PlotWorld other = PlotSquared.getPlotWorld(args[1]);
|
||||
PlotWorld current = PlotSquared.getPlotWorld(loc.getWorld());
|
||||
if (other == null || current == null || !other.equals(current)) {
|
||||
MainUtil.sendMessage(plr, C.PLOTWORLD_INCOMPATIBLE);
|
||||
return false;
|
||||
}
|
||||
world2 = other.worldname;
|
||||
}
|
||||
else {
|
||||
world2 = world;
|
||||
}
|
||||
Plot plot2 = MainUtil.getPlot(world2, plot2id);
|
||||
if (plot1.equals(plot2)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot move <X;Z>");
|
||||
return false;
|
||||
}
|
||||
if (MainUtil.move(world, plot1.id, plot2, new Runnable() {
|
||||
if (MainUtil.move(plot1, plot2, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(plr, C.MOVE_SUCCESS);
|
||||
|
@ -31,7 +31,6 @@ import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.BlockManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
|
@ -26,7 +26,6 @@ import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
public class Rate extends SubCommand {
|
||||
/*
|
||||
|
@ -22,7 +22,6 @@ package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -34,7 +33,6 @@ import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
/**
|
||||
* Created 2014-08-01 for PlotSquared
|
||||
|
@ -30,7 +30,6 @@ import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.util.EconHandler;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
public class Unclaim extends SubCommand {
|
||||
public Unclaim() {
|
||||
|
@ -32,7 +32,7 @@ import com.intellectualsites.translation.bukkit.BukkitTranslation;
|
||||
/**
|
||||
* Captions class.
|
||||
*
|
||||
* @author Citymonstret
|
||||
* @author Citymonstret
|
||||
*/
|
||||
public enum C {
|
||||
/*
|
||||
@ -260,6 +260,7 @@ public enum C {
|
||||
NOT_IN_PLOT("$2You're not in a plot"),
|
||||
NOT_IN_CLUSTER("$2You must be within a plot cluster to perform that action"),
|
||||
NOT_IN_PLOT_WORLD("$2You're not in a plot world"),
|
||||
PLOTWORLD_INCOMPATIBLE("$2The two worlds must be compatible"),
|
||||
NOT_VALID_WORLD("$2That is not a valid world (case sensitive)"),
|
||||
NOT_VALID_PLOT_WORLD("$2That is not a valid plot world (case sensitive)"),
|
||||
NO_PLOTS("$2You don't have any plots"),
|
||||
|
@ -328,5 +328,5 @@ public interface AbstractDB {
|
||||
|
||||
public void resizeCluster(PlotCluster current, PlotClusterId resize);
|
||||
|
||||
public void movePlot(String world, PlotId originalPlot, PlotId newPlot);
|
||||
public void movePlot(Plot originalPlot, Plot newPlot);
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ public class DBFunc {
|
||||
*/
|
||||
public static AbstractDB dbManager;
|
||||
|
||||
public static void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) {
|
||||
dbManager.movePlot(world, originalPlot, newPlot);
|
||||
public static void movePlot(final Plot originalPlot, final Plot newPlot) {
|
||||
dbManager.movePlot(originalPlot, newPlot);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -32,7 +32,6 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.object.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
|
@ -33,7 +33,6 @@ import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
|
@ -27,7 +27,6 @@ import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
|
||||
|
||||
/**
|
||||
* The plot class
|
||||
|
@ -21,10 +21,7 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package com.intellectualcrafters.plot.titles;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -25,7 +25,6 @@ import java.util.HashMap;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.intellectualcrafters.plot.PlotSquared;
|
||||
import com.intellectualcrafters.plot.commands.Claim;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
@ -41,7 +40,6 @@ import com.intellectualcrafters.plot.object.PlotSettings;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.PseudoRandom;
|
||||
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
|
||||
import com.intellectualcrafters.plot.util.bukkit.SendChunk;
|
||||
|
||||
/**
|
||||
* plot functions
|
||||
@ -807,14 +805,14 @@ public class MainUtil {
|
||||
Plot p2 = PlotSquared.getPlots(world).get(newPlot);
|
||||
if (p1 == null || p1.owner == null) {
|
||||
if (p2 != null && p2.owner != null) {
|
||||
moveData(world, newPlot, current, whenDone);
|
||||
moveData(p2, p1, whenDone);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if (p2 == null || p2.owner == null) {
|
||||
if (p1 != null && p1.owner != null) {
|
||||
moveData(world, current, newPlot, whenDone);
|
||||
moveData(p1, p2, whenDone);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -835,59 +833,58 @@ public class MainUtil {
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean moveData(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
|
||||
final Plot currentPlot = MainUtil.getPlot(world, current);
|
||||
if (currentPlot.owner == null) {
|
||||
public static boolean moveData(final Plot plot1, final Plot plot2, final Runnable whenDone) {
|
||||
if (plot1.owner == null) {
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
return false;
|
||||
}
|
||||
final Plot pos1 = getBottomPlot(currentPlot);
|
||||
final Plot pos2 = getTopPlot(currentPlot);
|
||||
final PlotId size = MainUtil.getSize(world, currentPlot);
|
||||
if (!MainUtil.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) {
|
||||
final Plot pos1 = getBottomPlot(plot1);
|
||||
final Plot pos2 = getTopPlot(plot1);
|
||||
final PlotId size = MainUtil.getSize(plot1.world, plot1);
|
||||
if (!MainUtil.isUnowned(plot2.world, plot2.id, new PlotId((plot2.id.x + size.x) - 1, (plot2.id.y + size.y) - 1))) {
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
return false;
|
||||
}
|
||||
final int offset_x = newPlot.x - pos1.id.x;
|
||||
final int offset_y = newPlot.y - pos1.id.y;
|
||||
final int offset_x = plot2.id.x - pos1.id.x;
|
||||
final int offset_y = plot2.id.y - pos1.id.y;
|
||||
final ArrayList<PlotId> selection = getPlotSelectionIds(pos1.id, pos2.id);
|
||||
for (final PlotId id : selection) {
|
||||
DBFunc.movePlot(world, new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y));
|
||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||
PlotSquared.getPlots(world).remove(id);
|
||||
DBFunc.movePlot(getPlot(plot1.world, new PlotId(id.x, id.y)), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
|
||||
final Plot plot = PlotSquared.getPlots(plot1.world).get(id);
|
||||
PlotSquared.getPlots(plot1.world).remove(id);
|
||||
plot.id.x += offset_x;
|
||||
plot.id.y += offset_y;
|
||||
PlotSquared.getPlots(world).put(plot.id, plot);
|
||||
PlotSquared.getPlots(plot2.world).put(plot.id, plot);
|
||||
}
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
public static boolean move(final String world, final PlotId current, final PlotId newPlot, final Runnable whenDone) {
|
||||
final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(world, current);
|
||||
final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(world, newPlot);
|
||||
final Location top = MainUtil.getPlotTopLoc(world, current);
|
||||
final Plot currentPlot = MainUtil.getPlot(world, current);
|
||||
if (currentPlot.owner == null) {
|
||||
public static boolean move(final Plot plot1, final Plot plot2, final Runnable whenDone) {
|
||||
final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(plot1.world, plot1.id);
|
||||
final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(plot1.world, plot1.id);
|
||||
final Location top = MainUtil.getPlotTopLoc(plot1.world, plot1.id);
|
||||
if (plot1.owner == null) {
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
return false;
|
||||
}
|
||||
final Plot pos1 = getBottomPlot(currentPlot);
|
||||
final Plot pos2 = getTopPlot(currentPlot);
|
||||
final PlotId size = MainUtil.getSize(world, currentPlot);
|
||||
if (!MainUtil.isUnowned(world, newPlot, new PlotId((newPlot.x + size.x) - 1, (newPlot.y + size.y) - 1))) {
|
||||
final Plot pos1 = getBottomPlot(plot1);
|
||||
final Plot pos2 = getTopPlot(plot1);
|
||||
final PlotId size = MainUtil.getSize(plot1.world, plot1);
|
||||
if (!MainUtil.isUnowned(plot2.world, plot2.id, new PlotId((plot2.id.x + size.x) - 1, (plot2.id.y + size.y) - 1))) {
|
||||
TaskManager.runTaskLater(whenDone, 1);
|
||||
return false;
|
||||
}
|
||||
final int offset_x = newPlot.x - pos1.id.x;
|
||||
final int offset_y = newPlot.y - pos1.id.y;
|
||||
final int offset_x = plot2.id.x - pos1.id.x;
|
||||
final int offset_y = plot2.id.y - pos1.id.y;
|
||||
final ArrayList<PlotId> selection = getPlotSelectionIds(pos1.id, pos2.id);
|
||||
for (final PlotId id : selection) {
|
||||
DBFunc.movePlot(world, new PlotId(id.x, id.y), new PlotId(id.x + offset_x, id.y + offset_y));
|
||||
final Plot plot = PlotSquared.getPlots(world).get(id);
|
||||
PlotSquared.getPlots(world).remove(id);
|
||||
DBFunc.movePlot(getPlot(plot1.world, new PlotId(id.x, id.y)), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
|
||||
final Plot plot = PlotSquared.getPlots(plot1.world).get(id);
|
||||
PlotSquared.getPlots(plot1.world).remove(id);
|
||||
plot.id.x += offset_x;
|
||||
plot.id.y += offset_y;
|
||||
PlotSquared.getPlots(world).put(plot.id, plot);
|
||||
PlotSquared.getPlots(plot2.world).put(plot.id, plot);
|
||||
}
|
||||
ChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() {
|
||||
@Override
|
||||
|
@ -155,28 +155,34 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
index.increment();
|
||||
final int relX = newPos.getX() - pos1.getX();
|
||||
final int relZ = newPos.getZ() - pos1.getZ();
|
||||
|
||||
final RegionWrapper region = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
|
||||
final World world = Bukkit.getWorld(pos1.getWorld());
|
||||
final Chunk c1 = world.getChunkAt(pos1.getX() >> 4, pos1.getZ() >> 4);
|
||||
final Chunk c2 = world.getChunkAt(pos2.getX() >> 4, pos2.getZ() >> 4);
|
||||
final Chunk c3 = world.getChunkAt((pos1.getX() + relX) >> 4, (pos1.getZ() + relZ) >> 4);
|
||||
final Chunk c4 = world.getChunkAt((pos2.getX() + relX) >> 4, (pos2.getZ() + relZ) >> 4);
|
||||
final World oldWorld = Bukkit.getWorld(pos1.getWorld());
|
||||
final World newWorld = Bukkit.getWorld(newPos.getWorld());
|
||||
|
||||
final Chunk c1 = newWorld.getChunkAt(pos1.getX() >> 4, pos1.getZ() >> 4);
|
||||
final Chunk c2 = newWorld.getChunkAt(pos2.getX() >> 4, pos2.getZ() >> 4);
|
||||
final Chunk c3 = newWorld.getChunkAt((pos1.getX() + relX) >> 4, (pos1.getZ() + relZ) >> 4);
|
||||
final Chunk c4 = newWorld.getChunkAt((pos2.getX() + relX) >> 4, (pos2.getZ() + relZ) >> 4);
|
||||
|
||||
final int sx = pos1.getX();
|
||||
final int sz = pos1.getZ();
|
||||
final int ex = pos2.getX();
|
||||
final int ez = pos2.getZ();
|
||||
|
||||
final int c1x = c1.getX();
|
||||
final int c1z = c1.getZ();
|
||||
final int c2x = c2.getX();
|
||||
final int c2z = c2.getZ();
|
||||
final int c3x = c3.getX();
|
||||
final int c3z = c3.getZ();
|
||||
|
||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
final ArrayList<Chunk> toGenerate = new ArrayList<>();
|
||||
// Load chunks
|
||||
for (int x = c2x; x <= c3x; x++) {
|
||||
for (int z = c2z; z <= c3z; z++) {
|
||||
final Chunk chunk = world.getChunkAt(x, z);
|
||||
final Chunk chunk = newWorld.getChunkAt(x, z);
|
||||
toGenerate.add(chunk);
|
||||
}
|
||||
}
|
||||
@ -198,17 +204,17 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
initMaps();
|
||||
for (int x = c1x; x <= c2x; x++) {
|
||||
for (int z = c1z; z <= c2z; z++) {
|
||||
final Chunk chunk = world.getChunkAt(x, z);
|
||||
final Chunk chunk = oldWorld.getChunkAt(x, z);
|
||||
chunks.add(chunk);
|
||||
chunk.load(false);
|
||||
saveEntitiesIn(chunk, region);
|
||||
}
|
||||
}
|
||||
restoreEntities(world, relX, relZ);
|
||||
restoreEntities(newWorld, relX, relZ);
|
||||
// Copy blocks
|
||||
final MutableInt mx = new MutableInt(sx);
|
||||
final Integer currentIndex = index.toInteger();
|
||||
final int maxY = world.getMaxHeight();
|
||||
final int maxY = oldWorld.getMaxHeight();
|
||||
final Integer task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -216,17 +222,17 @@ public class BukkitChunkManager extends ChunkManager {
|
||||
while ((System.currentTimeMillis() - start) < 25) {
|
||||
final int xv = mx.intValue();
|
||||
for (int z = sz; z <= ez; z++) {
|
||||
saveBlocks(world, maxY, xv, z);
|
||||
saveBlocks(oldWorld, maxY, xv, z);
|
||||
for (int y = 1; y <= maxY; y++) {
|
||||
final Block block = world.getBlockAt(xv, y, z);
|
||||
final Block block = oldWorld.getBlockAt(xv, y, z);
|
||||
final int id = block.getTypeId();
|
||||
final byte data = block.getData();
|
||||
BukkitSetBlockManager.setBlockManager.set(world, xv + relX, y, z + relZ, id, data);
|
||||
BukkitSetBlockManager.setBlockManager.set(newWorld, xv + relX, y, z + relZ, id, data);
|
||||
}
|
||||
}
|
||||
mx.increment();
|
||||
if (xv == ex) { // done!
|
||||
restoreBlocks(world, relX, relZ);
|
||||
restoreBlocks(newWorld, relX, relZ);
|
||||
BukkitSetBlockManager.setBlockManager.update(chunks);
|
||||
for (final Chunk chunk : chunks) {
|
||||
chunk.unload(true, true);
|
||||
|
Loading…
Reference in New Issue
Block a user