From 6ca922db67c619509732612b2635b2b211bb3fd0 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Sat, 9 Mar 2024 15:29:06 +0100 Subject: [PATCH] Add more getters to CompoundTag --- pom.xml | 2 +- .../opennbt/tag/builtin/CompoundTag.java | 105 ++++++++++++++++++ 2 files changed, 106 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 71f7d05..a44b5a1 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.viaversion nbt - 4.4.2 + 4.4.3 jar ViaNBT diff --git a/src/main/java/com/github/steveice10/opennbt/tag/builtin/CompoundTag.java b/src/main/java/com/github/steveice10/opennbt/tag/builtin/CompoundTag.java index 35f441f..483b38b 100644 --- a/src/main/java/com/github/steveice10/opennbt/tag/builtin/CompoundTag.java +++ b/src/main/java/com/github/steveice10/opennbt/tag/builtin/CompoundTag.java @@ -193,6 +193,36 @@ public final class CompoundTag extends Tag implements Iterable) tag : null; } + public @Nullable IntTag getIntTag(String tagName) { + final Tag tag = this.value.get(tagName); + return tag instanceof IntTag ? (IntTag) tag : null; + } + + public @Nullable LongTag getLongTag(String tagName) { + final Tag tag = this.value.get(tagName); + return tag instanceof LongTag ? (LongTag) tag : null; + } + + public @Nullable ShortTag getShortTag(String tagName) { + final Tag tag = this.value.get(tagName); + return tag instanceof ShortTag ? (ShortTag) tag : null; + } + + public @Nullable ByteTag getByteTag(String tagName) { + final Tag tag = this.value.get(tagName); + return tag instanceof ByteTag ? (ByteTag) tag : null; + } + + public @Nullable FloatTag getFloatTag(String tagName) { + final Tag tag = this.value.get(tagName); + return tag instanceof FloatTag ? (FloatTag) tag : null; + } + + public @Nullable DoubleTag getDoubleTag(String tagName) { + final Tag tag = this.value.get(tagName); + return tag instanceof DoubleTag ? (DoubleTag) tag : null; + } + public @Nullable NumberTag getNumberTag(String tagName) { final Tag tag = this.value.get(tagName); return tag instanceof NumberTag ? (NumberTag) tag : null; @@ -213,6 +243,81 @@ public final class CompoundTag extends Tag implements Iterable