2011-04-08 08:16:01 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using NDesk.Options;
|
|
|
|
|
using Substrate;
|
|
|
|
|
|
|
|
|
|
namespace NBToolkit
|
|
|
|
|
{
|
|
|
|
|
public class PurgeOptions : TKOptions, IChunkFilterable
|
|
|
|
|
{
|
|
|
|
|
private OptionSet _filterOpt = null;
|
|
|
|
|
private ChunkFilter _chunkFilter = null;
|
|
|
|
|
|
|
|
|
|
public PurgeOptions ()
|
|
|
|
|
: base()
|
|
|
|
|
{
|
|
|
|
|
_filterOpt = new OptionSet();
|
|
|
|
|
_chunkFilter = new ChunkFilter();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PurgeOptions (string[] args)
|
|
|
|
|
: this()
|
|
|
|
|
{
|
|
|
|
|
Parse(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Parse (string[] args)
|
|
|
|
|
{
|
|
|
|
|
base.Parse(args);
|
|
|
|
|
|
|
|
|
|
_filterOpt.Parse(args);
|
|
|
|
|
_chunkFilter.Parse(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void PrintUsage ()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Usage: nbtoolkit purge [options]");
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
Console.WriteLine("Options for command 'purge':");
|
|
|
|
|
|
|
|
|
|
_filterOpt.WriteOptionDescriptions(Console.Out);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
_chunkFilter.PrintUsage();
|
|
|
|
|
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
base.PrintUsage();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void SetDefaults ()
|
|
|
|
|
{
|
|
|
|
|
base.SetDefaults();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public IChunkFilter GetChunkFilter ()
|
|
|
|
|
{
|
|
|
|
|
return _chunkFilter;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class Purge : TKFilter
|
|
|
|
|
{
|
|
|
|
|
private PurgeOptions opt;
|
|
|
|
|
|
|
|
|
|
public Purge (PurgeOptions o)
|
|
|
|
|
{
|
|
|
|
|
opt = o;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void Run ()
|
|
|
|
|
{
|
2011-04-09 00:56:40 +00:00
|
|
|
|
NBTWorld world = GetWorld(opt);
|
|
|
|
|
FilteredChunkManager fcm = new FilteredChunkManager(world.ChunkManager, opt.GetChunkFilter());
|
2011-04-08 08:16:01 +00:00
|
|
|
|
|
|
|
|
|
int affectedChunks = 0;
|
2011-04-08 20:52:28 +00:00
|
|
|
|
foreach (ChunkRef chunk in fcm) {
|
2011-04-08 08:16:01 +00:00
|
|
|
|
affectedChunks++;
|
2011-04-09 00:56:40 +00:00
|
|
|
|
fcm.DeleteChunk(chunk.X, chunk.Z);
|
2011-04-08 08:16:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Purged Chunks: " + affectedChunks);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|