Skip to content

Commit

Permalink
Merge pull request #223 from SoSeDiK/tagcheck
Browse files Browse the repository at this point in the history
Allow checking nbt type alongside the key
  • Loading branch information
tr7zw authored May 6, 2023
2 parents 5759b68 + c485f8c commit 662c0bb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,8 @@ && getType(key) == NBTType.NBTTagIntArray) {
}

/**
* Checks whether the provided key exists
*
* @param key String key
* @return True if the key is set
* @deprecated Use {@link #hasTag(String)} instead
Expand All @@ -610,6 +612,8 @@ public Boolean hasKey(String key) {
}

/**
* Checks whether the provided key exists
*
* @param key String key
* @return true, if the key is set
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,24 @@ public interface ReadableNBT {
UUID getUUID(String key);

/**
* Checks whether the provided key exists
*
* @param key String key
* @return true, if the key is set
*/
boolean hasTag(String key);

/**
* Checks whether the provided key exists and has the specified type
*
* @param key String key
* @param type nbt tag type
* @return whether the key is set and has the specified type
*/
default boolean hasTag(String key, NBTType type) {
return hasTag(key) && getType(key) == type;
}

/**
* @return Set of all stored Keys
*/
Expand Down

0 comments on commit 662c0bb

Please sign in to comment.