mirror of
https://github.com/jaquadro/NBTExplorer.git
synced 2025-01-09 17:36:25 +00:00
37 lines
995 B
C#
37 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;
|
|
}
|
|
}
|
|
}
|