mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-04 03:56:41 +00:00
Re-add delchunks command (#481)
The new command now writes a json file to WorldEdit's working directory with instructions on which chunks to delete, which is read by the plugin/mod at startup and calls the ChunkDeleter. The chunk deleter parses the json and iterates the instructions, backing up .mca files as it goes and overwriting the offset headers with 0 wherever a chunk needs to be deleted. This allows Minecraft to reclaim the space used for that chunk, as well as forcing it to be generated from scratch next time the area is loaded.
This commit is contained in:
@ -34,6 +34,7 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.PriorityQueue;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
@ -56,6 +57,11 @@ public abstract class AbstractWorld implements World {
|
||||
return setBlock(pt, block, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getStoragePath() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxY() {
|
||||
return getMaximumPoint().getBlockY();
|
||||
|
@ -38,6 +38,9 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.weather.WeatherType;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* Represents a world (dimension).
|
||||
*/
|
||||
@ -50,6 +53,15 @@ public interface World extends Extent {
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Get the folder in which this world is stored. May return null if unknown
|
||||
* or if this world is not serialized to disk.
|
||||
*
|
||||
* @return world storage path
|
||||
*/
|
||||
@Nullable
|
||||
Path getStoragePath();
|
||||
|
||||
/**
|
||||
* Get the maximum Y.
|
||||
*
|
||||
|
@ -100,10 +100,9 @@ public class McRegionReader {
|
||||
/**
|
||||
* Read the header.
|
||||
*
|
||||
* @throws DataException
|
||||
* @throws IOException
|
||||
*/
|
||||
private void readHeader() throws DataException, IOException {
|
||||
private void readHeader() throws IOException {
|
||||
offsets = new int[SECTOR_INTS];
|
||||
|
||||
for (int i = 0; i < SECTOR_INTS; ++i) {
|
||||
@ -124,10 +123,6 @@ public class McRegionReader {
|
||||
int x = position.getBlockX() & 31;
|
||||
int z = position.getBlockZ() & 31;
|
||||
|
||||
if (x < 0 || x >= 32 || z < 0 || z >= 32) {
|
||||
throw new DataException("MCRegion file does not contain " + x + "," + z);
|
||||
}
|
||||
|
||||
int offset = getOffset(x, z);
|
||||
|
||||
// The chunk hasn't been generated
|
||||
@ -138,7 +133,7 @@ public class McRegionReader {
|
||||
int sectorNumber = offset >> 8;
|
||||
int numSectors = offset & 0xFF;
|
||||
|
||||
stream.seek(sectorNumber * SECTOR_BYTES);
|
||||
stream.seek((long) sectorNumber * SECTOR_BYTES);
|
||||
int length = dataStream.readInt();
|
||||
|
||||
if (length > SECTOR_BYTES * numSectors) {
|
||||
|
Reference in New Issue
Block a user