From 36bbe4844a0a68d4161b542b591a656b44e47711 Mon Sep 17 00:00:00 2001 From: ForeverZer0 Date: Tue, 24 Aug 2021 20:45:10 -0400 Subject: [PATCH] CompoundTag indexer using tag names implemented --- SharpNBT/Tags/CompoundTag.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/SharpNBT/Tags/CompoundTag.cs b/SharpNBT/Tags/CompoundTag.cs index 796ee13..42586df 100644 --- a/SharpNBT/Tags/CompoundTag.cs +++ b/SharpNBT/Tags/CompoundTag.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Runtime.Serialization; using System.Text; using JetBrains.Annotations; @@ -69,7 +68,7 @@ namespace SharpNBT { foreach (var tag in this) { - if (name.Equals(tag.Name)) + if (string.CompareOrdinal(name, tag.Name) == 0) return tag; if (deep && tag is CompoundTag child) @@ -83,6 +82,13 @@ namespace SharpNBT return null; } + /// + /// Retrieves a child tag with the specified , or if no match was found. + /// + /// The name of the tag to retrieve. + [CanBeNull] + public Tag this[[NotNull] string name] => Find(name, false); + /// protected internal override void PrettyPrinted(StringBuilder buffer, int level, string indent) {