mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 21:26:45 +01:00
Modifications to trim. fixed plot move/swap
This commit is contained in:
parent
7b2944c466
commit
2b3a4f738a
@ -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>
|
||||
|
@ -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) {
|
||||
|
@ -126,6 +126,11 @@ public class PlotId {
|
||||
|
||||
private int hash;
|
||||
|
||||
public void recalculateHash() {
|
||||
this.hash = 0;
|
||||
hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (hash == 0) {
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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)));
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user