Modifications to trim. fixed plot move/swap

This commit is contained in:
boy0001 2015-06-09 02:01:09 +10:00
parent 7b2944c466
commit 2b3a4f738a
6 changed files with 36 additions and 5 deletions

View File

@ -8,7 +8,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>
<artifactId>PlotSquared</artifactId> <artifactId>PlotSquared</artifactId>
<version>2.11.14</version> <version>2.11.15</version>
<name>PlotSquared</name> <name>PlotSquared</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<build> <build>

View File

@ -204,9 +204,7 @@ public class Trim extends SubCommand {
public static ArrayList<Plot> expired = null; public static ArrayList<Plot> expired = null;
public static void deleteChunks(final String world, final ArrayList<ChunkLoc> chunks) { public static void deleteChunks(final String world, final ArrayList<ChunkLoc> chunks) {
for (final ChunkLoc loc : chunks) { ChunkManager.manager.deleteRegionFiles(world, chunks);
ChunkManager.manager.deleteRegionFile(world, loc);
}
} }
public static void sendMessage(final String message) { public static void sendMessage(final String message) {

View File

@ -126,6 +126,11 @@ public class PlotId {
private int hash; private int hash;
public void recalculateHash() {
this.hash = 0;
hashCode();
}
@Override @Override
public int hashCode() { public int hashCode() {
if (hash == 0) { if (hash == 0) {

View File

@ -39,6 +39,8 @@ public abstract class ChunkManager {
public abstract void deleteRegionFile(final String world, final ChunkLoc loc); public abstract void deleteRegionFile(final String world, final ChunkLoc loc);
public abstract void deleteRegionFiles(final String world, final List<ChunkLoc> chunks);
public abstract Plot hasPlot(String world, ChunkLoc chunk); public abstract Plot hasPlot(String world, ChunkLoc chunk);
public abstract boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone); public abstract boolean copyRegion(final Location pos1, final Location pos2, final Location newPos, final Runnable whenDone);

View File

@ -1052,6 +1052,8 @@ public class MainUtil {
p2.id.y = temp.y; p2.id.y = temp.y;
PlotSquared.getPlots(world).remove(p1.id); PlotSquared.getPlots(world).remove(p1.id);
PlotSquared.getPlots(world).remove(p2.id); PlotSquared.getPlots(world).remove(p2.id);
p1.id.recalculateHash();
p2.id.recalculateHash();
PlotSquared.getPlots(world).put(p1.id, p1); PlotSquared.getPlots(world).put(p1.id, p1);
PlotSquared.getPlots(world).put(p2.id, p2); PlotSquared.getPlots(world).put(p2.id, p2);
// Swap database // Swap database
@ -1084,6 +1086,8 @@ public class MainUtil {
p2.id.y = temp.y; p2.id.y = temp.y;
PlotSquared.getPlots(world).remove(p1.id); PlotSquared.getPlots(world).remove(p1.id);
PlotSquared.getPlots(world).remove(p2.id); PlotSquared.getPlots(world).remove(p2.id);
p1.id.recalculateHash();
p2.id.recalculateHash();
PlotSquared.getPlots(world).put(p1.id, p1); PlotSquared.getPlots(world).put(p1.id, p1);
PlotSquared.getPlots(world).put(p2.id, p2); PlotSquared.getPlots(world).put(p2.id, p2);
// Swap database // Swap database
@ -1113,6 +1117,7 @@ public class MainUtil {
PlotSquared.getPlots(plot1.world).remove(id); PlotSquared.getPlots(plot1.world).remove(id);
plot.id.x += offset_x; plot.id.x += offset_x;
plot.id.y += offset_y; plot.id.y += offset_y;
plot.id.recalculateHash();
PlotSquared.getPlots(plot2.world).put(plot.id, plot); PlotSquared.getPlots(plot2.world).put(plot.id, plot);
} }
TaskManager.runTaskLater(whenDone, 1); TaskManager.runTaskLater(whenDone, 1);
@ -1142,6 +1147,7 @@ public class MainUtil {
PlotSquared.getPlots(plot1.world).remove(id); PlotSquared.getPlots(plot1.world).remove(id);
plot.id.x += offset_x; plot.id.x += offset_x;
plot.id.y += offset_y; plot.id.y += offset_y;
plot.id.recalculateHash();
PlotSquared.getPlots(plot2.world).put(plot.id, plot); PlotSquared.getPlots(plot2.world).put(plot.id, plot);
DBFunc.movePlot(getPlot(worldOriginal, idOriginal), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y))); DBFunc.movePlot(getPlot(worldOriginal, idOriginal), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y)));
} }

View File

@ -99,6 +99,25 @@ public class BukkitChunkManager extends ChunkManager {
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
public void run() { public void run() {
final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
final File file = new File(directory);
PlotSquared.log("&6 - Deleting region: " + file.getName() + " (approx 1024 chunks)");
if (file.exists()) {
file.delete();
}
try {
Thread.sleep(100);
} catch (InterruptedException e) {}
}
});
}
@Override
public void deleteRegionFiles(final String world, final List<ChunkLoc> chunks) {
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
for (ChunkLoc loc : chunks) {
final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca"; final String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
final File file = new File(directory); final File file = new File(directory);
PlotSquared.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)"); PlotSquared.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
@ -106,6 +125,7 @@ public class BukkitChunkManager extends ChunkManager {
file.delete(); file.delete();
} }
} }
}
}); });
} }