From f243f76d6f45ff1b5b46636cdd0554231bae50fb Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Mon, 16 Oct 2023 15:24:21 +1000 Subject: [PATCH] 3.1.0 Release Add NumberTag#asBoolean --- README.md | 2 +- pom.xml | 2 +- .../steveice10/opennbt/tag/builtin/ListTag.java | 2 +- .../steveice10/opennbt/tag/builtin/NumberTag.java | 12 ++++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f48e8a8..95ff744 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ This project also includes code from [adventure](https://github.com/KyoriPowered com.viaversion nbt - 3.0.0 + 3.1.0 ``` diff --git a/pom.xml b/pom.xml index 7cbe020..5fe8ea9 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.viaversion nbt - 3.0.0 + 3.1.0 jar ViaNBT diff --git a/src/main/java/com/github/steveice10/opennbt/tag/builtin/ListTag.java b/src/main/java/com/github/steveice10/opennbt/tag/builtin/ListTag.java index c701523..04f213a 100644 --- a/src/main/java/com/github/steveice10/opennbt/tag/builtin/ListTag.java +++ b/src/main/java/com/github/steveice10/opennbt/tag/builtin/ListTag.java @@ -77,7 +77,7 @@ public class ListTag extends Tag implements Iterable { * * @return The ListTag's element type, or null if the list does not yet have a defined type. */ - public Class getElementType() { + public @Nullable Class getElementType() { return this.type; } diff --git a/src/main/java/com/github/steveice10/opennbt/tag/builtin/NumberTag.java b/src/main/java/com/github/steveice10/opennbt/tag/builtin/NumberTag.java index 13942f5..bccccd7 100644 --- a/src/main/java/com/github/steveice10/opennbt/tag/builtin/NumberTag.java +++ b/src/main/java/com/github/steveice10/opennbt/tag/builtin/NumberTag.java @@ -46,4 +46,16 @@ public abstract class NumberTag extends Tag { * @return Double value of this tag. */ public abstract double asDouble(); + + /** + * Gets the boolean value of this tag. + *

+ * Booleans do not have a direct nbt representation in NBT per se, + * but check whether a number value is different to 0. + * + * @return Boolean value of this tag. + */ + public boolean asBoolean() { + return this.asByte() != 0; + } }