Skip to content

Commit

Permalink
Merge pull request #1088 from RealBauHD/feat/isEmpty
Browse files Browse the repository at this point in the history
feat(nbt): add isEmpty to CompoundBinaryTag/ListBinaryTag
  • Loading branch information
zml2008 authored Oct 6, 2024
2 parents fc302fd + 2a7b004 commit 4967d24
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ public interface CompoundBinaryTag extends BinaryTag, CompoundTagSetter<Compound
*/
int size();

/**
* Returns whether the compound has tags or not.
*
* @return false if the compound has tags
* @since 4.18.0
*/
boolean isEmpty();

/**
* Gets a boolean.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public int size() {
return this.tags.size();
}

@Override
public boolean isEmpty() {
return this.tags.isEmpty();
}

@Override
public @NotNull CompoundBinaryTag put(final @NotNull String key, final @NotNull BinaryTag tag) {
return this.edit(map -> map.put(key, tag));
Expand Down
8 changes: 8 additions & 0 deletions nbt/src/main/java/net/kyori/adventure/nbt/ListBinaryTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ public interface ListBinaryTag extends ListTagSetter<ListBinaryTag, BinaryTag>,
*/
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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 4967d24

Please sign in to comment.