mirror of
https://github.com/jaquadro/NBTExplorer.git
synced 2025-01-10 01:46:24 +00:00
38 lines
995 B
C#
38 lines
995 B
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Text;
|
|||
|
using NBTExplorer.Model;
|
|||
|
using Substrate.Nbt;
|
|||
|
|
|||
|
namespace NBTUtil.Ops
|
|||
|
{
|
|||
|
class SetListOperation : ConsoleOperation
|
|||
|
{
|
|||
|
public override bool CanProcess (DataNode dataNode)
|
|||
|
{
|
|||
|
if (!(dataNode is TagListDataNode))
|
|||
|
return false;
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
|
|||
|
public override bool Process (DataNode dataNode, ConsoleOptions options)
|
|||
|
{
|
|||
|
TagListDataNode listNode = dataNode as TagListDataNode;
|
|||
|
|
|||
|
listNode.Clear();
|
|||
|
foreach (string value in options.Values) {
|
|||
|
TagNode tag = TagDataNode.DefaultTag(listNode.Tag.ValueType);
|
|||
|
TagDataNode tagData = TagDataNode.CreateFromTag(tag);
|
|||
|
if (!tagData.Parse(value))
|
|||
|
return false;
|
|||
|
|
|||
|
if (!listNode.AppendTag(tagData.Tag))
|
|||
|
return false;
|
|||
|
}
|
|||
|
|
|||
|
return true;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|