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>
</properties>
<artifactId>PlotSquared</artifactId>
<version>2.11.14</version>
<version>2.11.15</version>
<name>PlotSquared</name>
<packaging>jar</packaging>
<build>

View File

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

View File

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

View File

@ -38,6 +38,8 @@ public abstract class ChunkManager {
public abstract List<ChunkLoc> getChunkChunks(String world);
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);

View File

@ -1052,6 +1052,8 @@ public class MainUtil {
p2.id.y = temp.y;
PlotSquared.getPlots(world).remove(p1.id);
PlotSquared.getPlots(world).remove(p2.id);
p1.id.recalculateHash();
p2.id.recalculateHash();
PlotSquared.getPlots(world).put(p1.id, p1);
PlotSquared.getPlots(world).put(p2.id, p2);
// Swap database
@ -1084,6 +1086,8 @@ public class MainUtil {
p2.id.y = temp.y;
PlotSquared.getPlots(world).remove(p1.id);
PlotSquared.getPlots(world).remove(p2.id);
p1.id.recalculateHash();
p2.id.recalculateHash();
PlotSquared.getPlots(world).put(p1.id, p1);
PlotSquared.getPlots(world).put(p2.id, p2);
// Swap database
@ -1113,6 +1117,7 @@ public class MainUtil {
PlotSquared.getPlots(plot1.world).remove(id);
plot.id.x += offset_x;
plot.id.y += offset_y;
plot.id.recalculateHash();
PlotSquared.getPlots(plot2.world).put(plot.id, plot);
}
TaskManager.runTaskLater(whenDone, 1);
@ -1142,6 +1147,7 @@ public class MainUtil {
PlotSquared.getPlots(plot1.world).remove(id);
plot.id.x += offset_x;
plot.id.y += offset_y;
plot.id.recalculateHash();
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)));
}

View File

@ -101,10 +101,30 @@ public class BukkitChunkManager extends ChunkManager {
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 file: " + file.getName() + " (max 1024 chunks)");
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 File file = new File(directory);
PlotSquared.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
if (file.exists()) {
file.delete();
}
}
}
});
}