mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
MOVE!
This commit is contained in:
parent
37febd40b7
commit
dd152ce28e
@ -68,8 +68,12 @@ public class Move extends SubCommand {
|
|||||||
PlayerFunctions.sendMessage(plr, "DUPLICATE ID");
|
PlayerFunctions.sendMessage(plr, "DUPLICATE ID");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (move(world, plot1, plot2, null)) {
|
if (move(world, plot1, plot2, new Runnable() {
|
||||||
PlayerFunctions.sendMessage(plr, "MOVE SUCCESS");
|
@Override
|
||||||
|
public void run() {
|
||||||
|
PlayerFunctions.sendMessage(plr, "MOVE SUCCESS");
|
||||||
|
}
|
||||||
|
})) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -122,7 +122,7 @@ public class Trim extends SubCommand {
|
|||||||
if (Trim.TASK) {
|
if (Trim.TASK) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String directory = world.getName() + File.separator + "region";
|
String directory = world.getName() + File.separator + "region";
|
||||||
@ -169,7 +169,7 @@ public class Trim extends SubCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Trim.TASK = false;
|
Trim.TASK = false;
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTaskAsync(whenDone);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Trim.TASK = true;
|
Trim.TASK = true;
|
||||||
@ -197,7 +197,7 @@ public class Trim extends SubCommand {
|
|||||||
empty.addAll(chunks);
|
empty.addAll(chunks);
|
||||||
System.out.print("DONE!");
|
System.out.print("DONE!");
|
||||||
Trim.TASK = false;
|
Trim.TASK = false;
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTaskAsync(whenDone);
|
||||||
Bukkit.getScheduler().cancelTask(Trim.TASK_ID);
|
Bukkit.getScheduler().cancelTask(Trim.TASK_ID);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setOwner(final Plot plot, final UUID uuid) {
|
public void setOwner(final Plot plot, final UUID uuid) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -308,7 +308,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void createPlot(final Plot plot) {
|
public void createPlot(final Plot plot) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -330,7 +330,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createPlotAndSettings(final Plot plot) {
|
public void createPlotAndSettings(final Plot plot) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -410,7 +410,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
@Override
|
@Override
|
||||||
public void delete(final String world, final Plot plot) {
|
public void delete(final String world, final Plot plot) {
|
||||||
PlotMain.removePlot(world, plot.id, false);
|
PlotMain.removePlot(world, plot.id, false);
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -451,7 +451,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void createPlotSettings(final int id, final Plot plot) {
|
public void createPlotSettings(final int id, final Plot plot) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -730,7 +730,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
@Override
|
@Override
|
||||||
public void setMerged(final String world, final Plot plot, final boolean[] merged) {
|
public void setMerged(final String world, final Plot plot, final boolean[] merged) {
|
||||||
plot.settings.setMerged(merged);
|
plot.settings.setMerged(merged);
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -753,7 +753,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void swapPlots(final Plot p1, final Plot p2) {
|
public void swapPlots(final Plot p1, final Plot p2) {
|
||||||
TaskManager.runTask(
|
TaskManager.runTaskAsync(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -790,7 +790,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) {
|
public void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) {
|
||||||
TaskManager.runTask(
|
TaskManager.runTaskAsync(
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@ -821,7 +821,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
|
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -846,7 +846,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final String flag_string = StringUtils.join(newflags, ",");
|
final String flag_string = StringUtils.join(newflags, ",");
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -870,7 +870,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
@Override
|
@Override
|
||||||
public void setAlias(final String world, final Plot plot, final String alias) {
|
public void setAlias(final String world, final Plot plot, final String alias) {
|
||||||
plot.settings.setAlias(alias);
|
plot.settings.setAlias(alias);
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -962,7 +962,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setPosition(final String world, final Plot plot, final String position) {
|
public void setPosition(final String world, final Plot plot, final String position) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -1034,7 +1034,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeComment(final String world, final Plot plot, final PlotComment comment) {
|
public void removeComment(final String world, final Plot plot, final PlotComment comment) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -1095,7 +1095,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setComment(final String world, final Plot plot, final PlotComment comment) {
|
public void setComment(final String world, final Plot plot, final PlotComment comment) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -1121,7 +1121,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removeHelper(final String world, final Plot plot, final UUID uuid) {
|
public void removeHelper(final String world, final Plot plot, final UUID uuid) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -1144,7 +1144,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removeTrusted(final String world, final Plot plot, final UUID uuid) {
|
public void removeTrusted(final String world, final Plot plot, final UUID uuid) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -1167,7 +1167,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setHelper(final String world, final Plot plot, final UUID uuid) {
|
public void setHelper(final String world, final Plot plot, final UUID uuid) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -1185,7 +1185,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setHelper(final int id, final UUID uuid) {
|
public void setHelper(final int id, final UUID uuid) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -1208,7 +1208,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setTrusted(final String world, final Plot plot, final UUID uuid) {
|
public void setTrusted(final String world, final Plot plot, final UUID uuid) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -1231,7 +1231,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void removeDenied(final String world, final Plot plot, final UUID uuid) {
|
public void removeDenied(final String world, final Plot plot, final UUID uuid) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -1254,7 +1254,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setDenied(final String world, final Plot plot, final UUID uuid) {
|
public void setDenied(final String world, final Plot plot, final UUID uuid) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -1293,7 +1293,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
@Override
|
@Override
|
||||||
public void delete(final PlotCluster cluster) {
|
public void delete(final PlotCluster cluster) {
|
||||||
ClusterManager.removeCluster(cluster);
|
ClusterManager.removeCluster(cluster);
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -1548,7 +1548,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
|
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -1569,7 +1569,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
@Override
|
@Override
|
||||||
public void setClusterName(final PlotCluster cluster, final String name) {
|
public void setClusterName(final PlotCluster cluster, final String name) {
|
||||||
cluster.settings.setAlias(name);
|
cluster.settings.setAlias(name);
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -1590,7 +1590,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeHelper(final PlotCluster cluster, final UUID uuid) {
|
public void removeHelper(final PlotCluster cluster, final UUID uuid) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -1609,7 +1609,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setHelper(final PlotCluster cluster, final UUID uuid) {
|
public void setHelper(final PlotCluster cluster, final UUID uuid) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -1628,7 +1628,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createCluster(final PlotCluster cluster) {
|
public void createCluster(final PlotCluster cluster) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -1663,7 +1663,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
final PlotId pos2 = new PlotId(current.getP2().x, current.getP2().y);
|
final PlotId pos2 = new PlotId(current.getP2().x, current.getP2().y);
|
||||||
current.setP1(resize.pos1);
|
current.setP1(resize.pos1);
|
||||||
current.setP2(resize.pos2);
|
current.setP2(resize.pos2);
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -1686,7 +1686,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setPosition(final PlotCluster cluster, final String position) {
|
public void setPosition(final PlotCluster cluster, final String position) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
PreparedStatement stmt = null;
|
PreparedStatement stmt = null;
|
||||||
@ -1753,7 +1753,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeInvited(final PlotCluster cluster, final UUID uuid) {
|
public void removeInvited(final PlotCluster cluster, final UUID uuid) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
@ -1773,7 +1773,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInvited(String world, final PlotCluster cluster, final UUID uuid) {
|
public void setInvited(String world, final PlotCluster cluster, final UUID uuid) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
|
@ -77,7 +77,7 @@ public class ChunkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void deleteRegionFile(final String world, final ChunkLoc loc) {
|
public static void deleteRegionFile(final String world, final ChunkLoc loc) {
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
|
String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
|
||||||
@ -138,14 +138,14 @@ public class ChunkManager {
|
|||||||
final int relX = newPos.getBlockX() - pos1.getBlockX();
|
final int relX = newPos.getBlockX() - pos1.getBlockX();
|
||||||
final int relZ = newPos.getBlockZ() - pos1.getBlockZ();
|
final int relZ = newPos.getBlockZ() - pos1.getBlockZ();
|
||||||
System.out.print(relX + "," + relZ);
|
System.out.print(relX + "," + relZ);
|
||||||
RegionWrapper region = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ());
|
final RegionWrapper region = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ());
|
||||||
|
|
||||||
final World world = pos1.getWorld();
|
final World world = pos1.getWorld();
|
||||||
Chunk c1 = world.getChunkAt(pos1);
|
Chunk c1 = world.getChunkAt(pos1);
|
||||||
Chunk c2 = world.getChunkAt(pos2);
|
Chunk c2 = world.getChunkAt(pos2);
|
||||||
|
|
||||||
Chunk c3 = world.getChunkAt(pos1.getBlockX() + relX, pos1.getBlockZ() + relZ);
|
Chunk c3 = world.getChunkAt((pos1.getBlockX() + relX) >> 4, (pos1.getBlockZ() + relZ) >> 4);
|
||||||
Chunk c4 = world.getChunkAt(pos2.getBlockX() + relX, pos2.getBlockZ() + relZ);
|
Chunk c4 = world.getChunkAt((pos2.getBlockX() + relX) >> 4, (pos2.getBlockZ() + relZ) >> 4);
|
||||||
|
|
||||||
final int sx = pos1.getBlockX();
|
final int sx = pos1.getBlockX();
|
||||||
final int sz = pos1.getBlockZ();
|
final int sz = pos1.getBlockZ();
|
||||||
@ -162,64 +162,90 @@ public class ChunkManager {
|
|||||||
final int c4x = c4.getX();
|
final int c4x = c4.getX();
|
||||||
final int c4z = c4.getZ();
|
final int c4z = c4.getZ();
|
||||||
|
|
||||||
// Copy entities
|
|
||||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||||
initMaps();
|
final ArrayList<Chunk> toGenerate = new ArrayList<>();
|
||||||
for (int x = c3x; x <= c4x; x ++) {
|
|
||||||
for (int z = c3z; z <= c4z; z ++) {
|
|
||||||
Chunk chunk = world.getChunkAt(x, z);
|
|
||||||
chunks.add(chunk);
|
|
||||||
chunk.load(false);
|
|
||||||
saveEntitiesIn(chunk, region);
|
|
||||||
restoreEntities(world, relX, relZ);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Load chunks
|
// Load chunks
|
||||||
for (int x = c1x; x <= c2x; x ++) {
|
for (int x = c1x; x <= c2x; x ++) {
|
||||||
for (int z = c1z; z <= c2z; z ++) {
|
for (int z = c1z; z <= c2z; z ++) {
|
||||||
Chunk chunk = world.getChunkAt(x, z);
|
Chunk chunk = world.getChunkAt(x, z);
|
||||||
chunk.load(true);
|
toGenerate.add(chunk);
|
||||||
chunks.add(chunk);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy blocks
|
|
||||||
final MutableInt mx = new MutableInt(sx);
|
|
||||||
final Plugin plugin = (Plugin) PlotMain.getMain();
|
final Plugin plugin = (Plugin) PlotMain.getMain();
|
||||||
final Integer currentIndex = index.toInteger();
|
final Integer currentIndex = index.toInteger();
|
||||||
final int maxY = world.getMaxHeight();
|
final int loadTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||||
final Integer task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
long start = System.currentTimeMillis();
|
if (toGenerate.size() == 0) {
|
||||||
while (System.currentTimeMillis() - start < 20) {
|
Bukkit.getScheduler().cancelTask(tasks.get(currentIndex));
|
||||||
int x = mx.intValue();
|
tasks.remove(currentIndex);
|
||||||
System.out.print(x);
|
TaskManager.runTask(new Runnable() {
|
||||||
for (int z = sz; z <= ez; z++) {
|
@Override
|
||||||
saveBlocks(world, maxY, x, z);
|
public void run() {
|
||||||
for (int y = 1; y <= maxY; y++) {
|
System.out.print("================== SETTING BLOCKS ===================");
|
||||||
Block block = world.getBlockAt(x, y, z);
|
index.increment();
|
||||||
int id = block.getTypeId();
|
// Copy entities
|
||||||
byte data = block.getData();
|
initMaps();
|
||||||
AbstractSetBlock.setBlockManager.set(world, x + relX, y, z + relZ, id, data);
|
for (int x = c3x; x <= c4x; x ++) {
|
||||||
|
for (int z = c3z; z <= c4z; z ++) {
|
||||||
|
Chunk chunk = world.getChunkAt(x, z);
|
||||||
|
System.out.print("SAVING ENTITIES: " + chunk);
|
||||||
|
chunks.add(chunk);
|
||||||
|
chunk.load(false);
|
||||||
|
saveEntitiesIn(chunk, region);
|
||||||
|
restoreEntities(world, relX, relZ);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Copy blocks
|
||||||
|
final MutableInt mx = new MutableInt(sx);
|
||||||
|
final Integer currentIndex = index.toInteger();
|
||||||
|
final int maxY = world.getMaxHeight();
|
||||||
|
final Integer task = Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
System.out.print(" - " + mx.intValue());
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
while (System.currentTimeMillis() - start < 20) {
|
||||||
|
int x = mx.intValue();
|
||||||
|
System.out.print(x);
|
||||||
|
for (int z = sz; z <= ez; z++) {
|
||||||
|
saveBlocks(world, maxY, x, z);
|
||||||
|
for (int y = 1; y <= maxY; y++) {
|
||||||
|
Block block = world.getBlockAt(x, y, z);
|
||||||
|
int id = block.getTypeId();
|
||||||
|
byte data = block.getData();
|
||||||
|
AbstractSetBlock.setBlockManager.set(world, x + relX, y, z + relZ, id, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mx.increment();
|
||||||
|
if (x + 1 == ex) { // done!
|
||||||
|
restoreBlocks(world, relX, relZ);
|
||||||
|
AbstractSetBlock.setBlockManager.update(chunks);
|
||||||
|
for (Chunk chunk : chunks) {
|
||||||
|
chunk.unload(true, true);
|
||||||
|
}
|
||||||
|
TaskManager.runTaskLater(whenDone, 1);
|
||||||
|
Bukkit.getScheduler().cancelTask(tasks.get(currentIndex));
|
||||||
|
tasks.remove(currentIndex);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, 1, 1);
|
||||||
|
tasks.put(currentIndex, task);
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
mx.increment();
|
return;
|
||||||
if (x + 1 == ex) { // done!
|
|
||||||
restoreBlocks(world, relX, relZ);
|
|
||||||
AbstractSetBlock.setBlockManager.update(chunks);
|
|
||||||
for (Chunk chunk : chunks) {
|
|
||||||
chunk.unload(true, true);
|
|
||||||
}
|
|
||||||
TaskManager.runTaskLater(whenDone, 1);
|
|
||||||
Bukkit.getScheduler().cancelTask(tasks.get(currentIndex));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
Chunk chunk = toGenerate.get(0);
|
||||||
}, 1, 1);
|
toGenerate.remove(0);
|
||||||
tasks.put(currentIndex, task);
|
chunk.load(true);
|
||||||
|
chunks.add(chunk);
|
||||||
|
System.out.print("GENERATING CHUNK: " + chunk);
|
||||||
|
}
|
||||||
|
}, 1l, 1l);
|
||||||
|
tasks.put(currentIndex, loadTask);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,6 +283,7 @@ public class ChunkManager {
|
|||||||
if (chunks.size() == 0) {
|
if (chunks.size() == 0) {
|
||||||
TaskManager.runTaskLater(whenDone, 1);
|
TaskManager.runTaskLater(whenDone, 1);
|
||||||
Bukkit.getScheduler().cancelTask(tasks.get(currentIndex));
|
Bukkit.getScheduler().cancelTask(tasks.get(currentIndex));
|
||||||
|
tasks.remove(currentIndex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ());
|
CURRENT_PLOT_CLEAR = new RegionWrapper(pos1.getBlockX(), pos2.getBlockX(), pos1.getBlockZ(), pos2.getBlockZ());
|
||||||
|
@ -44,7 +44,7 @@ public class ExpireManager {
|
|||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (now > getTimeStamp(world)) {
|
if (now > getTimeStamp(world)) {
|
||||||
timestamp.put(world, now + 86400000l);
|
timestamp.put(world, now + 86400000l);
|
||||||
TaskManager.runTask(new Runnable() {
|
TaskManager.runTaskAsync(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
HashMap<Plot, Long> plots = getOldPlots(world);
|
HashMap<Plot, Long> plots = getOldPlots(world);
|
||||||
|
@ -8,10 +8,14 @@ public class TaskManager {
|
|||||||
|
|
||||||
public static HashSet<String> TELEPORT_QUEUE = new HashSet<>();
|
public static HashSet<String> TELEPORT_QUEUE = new HashSet<>();
|
||||||
|
|
||||||
public static void runTask(final Runnable r) {
|
public static void runTaskAsync(final Runnable r) {
|
||||||
PlotMain.getMain().getServer().getScheduler().runTaskAsynchronously(PlotMain.getMain(), r);
|
PlotMain.getMain().getServer().getScheduler().runTaskAsynchronously(PlotMain.getMain(), r);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void runTask(final Runnable r) {
|
||||||
|
PlotMain.getMain().getServer().getScheduler().runTask(PlotMain.getMain(), r);
|
||||||
|
}
|
||||||
|
|
||||||
public static void runTaskLater(final Runnable r, int delay) {
|
public static void runTaskLater(final Runnable r, int delay) {
|
||||||
if (r == null) {
|
if (r == null) {
|
||||||
return;
|
return;
|
||||||
|
Loading…
Reference in New Issue
Block a user