Debug mode for anvil unclaimed filter
This commit is contained in:
parent
8564b0b80f
commit
fe07915f52
@ -232,10 +232,11 @@ public class AnvilCommands {
|
||||
max = 3
|
||||
)
|
||||
@CommandPermissions("worldedit.anvil.deleteallunclaimed")
|
||||
public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Optional("60000") int fileDurationMillis) throws WorldEditException {
|
||||
public void deleteAllUnclaimed(Player player, int inhabitedTicks, @Optional("60000") int fileDurationMillis, @Switch('d') boolean debug) throws WorldEditException {
|
||||
String folder = Fawe.imp().getWorldName(player.getWorld());
|
||||
long chunkInactivityMillis = fileDurationMillis; // Use same value for now
|
||||
DeleteUnclaimedFilter filter = new DeleteUnclaimedFilter(player.getWorld(), fileDurationMillis, inhabitedTicks, chunkInactivityMillis);
|
||||
if (debug) filter.enableDebug();
|
||||
DeleteUnclaimedFilter result = runWithWorld(player, folder, filter, true);
|
||||
if (result != null) player.print(BBC.getPrefix() + BBC.VISITOR_BLOCK.format(result.getTotal()));
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.boydti.fawe.jnbt.anvil.filters;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.jnbt.NBTStreamer;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAChunk;
|
||||
import com.boydti.fawe.jnbt.anvil.MCAFile;
|
||||
@ -12,6 +13,7 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.attribute.BasicFileAttributes;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@ -23,6 +25,7 @@ public class DeleteUninhabitedFilter extends MCAFilterCounter {
|
||||
private final long inhabitedTicks;
|
||||
private final long fileDurationMillis;
|
||||
private final long cutoffChunkAgeEpoch;
|
||||
private boolean debug = false;
|
||||
|
||||
public DeleteUninhabitedFilter(long fileDurationMillis, long inhabitedTicks, long chunkInactivityMillis) {
|
||||
this.fileDurationMillis = fileDurationMillis;
|
||||
@ -30,6 +33,10 @@ public class DeleteUninhabitedFilter extends MCAFilterCounter {
|
||||
this.cutoffChunkAgeEpoch = System.currentTimeMillis() - chunkInactivityMillis;
|
||||
}
|
||||
|
||||
public void enableDebug() {
|
||||
this.debug = true;
|
||||
}
|
||||
|
||||
public long getInhabitedTicks() {
|
||||
return inhabitedTicks;
|
||||
}
|
||||
@ -55,6 +62,9 @@ public class DeleteUninhabitedFilter extends MCAFilterCounter {
|
||||
}
|
||||
try {
|
||||
if (shouldDelete(file, attr, mcaX, mcaZ)) {
|
||||
if (debug) {
|
||||
Fawe.debug("Deleting " + file + " as it was modified at " + new Date(lastModified) + " and you provided a threshold of " + new Date(cutoffChunkAgeEpoch));
|
||||
}
|
||||
file.delete();
|
||||
get().add(512 * 512 * 256);
|
||||
return false;
|
||||
@ -134,6 +144,11 @@ public class DeleteUninhabitedFilter extends MCAFilterCounter {
|
||||
public void run(Integer index, Long value) {
|
||||
if (value <= inhabitedTicks) {
|
||||
MCAChunk chunk = new MCAChunk(null, x, z);
|
||||
if (debug) {
|
||||
int cx = (mca.getX() << 5) + (x & 31);
|
||||
int cz = (mca.getZ() << 5) + (z & 31);
|
||||
Fawe.debug("Deleting chunk " + cx + "," + cz + " as it was only inhabited for " + value + " and passed all other checks");
|
||||
}
|
||||
chunk.setDeleted(true);
|
||||
synchronized (mca) {
|
||||
mca.setChunk(chunk);
|
||||
|
Loading…
Reference in New Issue
Block a user