Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nbt): add isEmpty to CompoundBinaryTag/ListBinaryTag #1088

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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