From 2a7b004b3de089b3dc8820e9dc184be638c78c84 Mon Sep 17 00:00:00 2001 From: Aaron Date: Mon, 1 Jul 2024 15:01:38 +0200 Subject: [PATCH] feat(nbt): add isEmpty to CompoundBinaryTag/ListBinaryTag --- .../java/net/kyori/adventure/nbt/CompoundBinaryTag.java | 8 ++++++++ .../net/kyori/adventure/nbt/CompoundBinaryTagImpl.java | 5 +++++ .../main/java/net/kyori/adventure/nbt/ListBinaryTag.java | 8 ++++++++ .../java/net/kyori/adventure/nbt/ListBinaryTagImpl.java | 5 +++++ 4 files changed, 26 insertions(+) diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/CompoundBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/CompoundBinaryTag.java index 843b2748e..f6c4cdd3f 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/CompoundBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/CompoundBinaryTag.java @@ -99,6 +99,14 @@ public interface CompoundBinaryTag extends BinaryTag, CompoundTagSetter map.put(key, tag)); diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java b/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java index 085393305..3d5d2595d 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java @@ -154,6 +154,14 @@ public interface ListBinaryTag extends ListTagSetter, */ int size(); + /** + * Returns whether the list has elements or not. + * + * @return false if the list has elements + * @since 4.18.0 + */ + boolean isEmpty(); + /** * Gets a tag. * diff --git a/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTagImpl.java b/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTagImpl.java index 424016fab..3af393ae1 100644 --- a/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTagImpl.java +++ b/nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTagImpl.java @@ -61,6 +61,11 @@ public int size() { return this.tags.size(); } + @Override + public boolean isEmpty() { + return this.tags.isEmpty(); + } + @Override public @NotNull BinaryTag get(@Range(from = 0, to = Integer.MAX_VALUE) final int index) { return this.tags.get(index);