mirror of
https://github.com/ViaVersion/ViaNBT.git
synced 2024-11-22 11:35:16 +01:00
Add getUnchecked method to CompoundTag
This commit is contained in:
parent
9be057263f
commit
921fa31b29
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.viaversion</groupId>
|
<groupId>com.viaversion</groupId>
|
||||||
<artifactId>nbt</artifactId>
|
<artifactId>nbt</artifactId>
|
||||||
<version>4.4.1</version>
|
<version>4.4.2</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>ViaNBT</name>
|
<name>ViaNBT</name>
|
||||||
|
@ -129,19 +129,33 @@ public final class CompoundTag extends Tag implements Iterable<Entry<String, Tag
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the tag.
|
* Returns a tag by name if present.
|
||||||
* <p>
|
* <p>
|
||||||
* <b>This will have its generic removed and instead return a raw tag in the future.</b>
|
* <b>This will have its generic removed and instead return a raw tag in the future.</b>
|
||||||
*
|
*
|
||||||
* @param <T> Type of tag to get.
|
* @param <T> type of the tag
|
||||||
* @param tagName Name of the tag.
|
* @param tagName key of the tag
|
||||||
* @return The tag.
|
* @return tag if present, else null
|
||||||
|
* @see #getUnchecked(String)
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public <T extends Tag> T get(String tagName) {
|
public <T extends Tag> T get(String tagName) {
|
||||||
return (T) this.value.get(tagName);
|
return (T) this.value.get(tagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a tag by name if present.
|
||||||
|
*
|
||||||
|
* @param <T> type of the tag
|
||||||
|
* @param tagName key of the tag
|
||||||
|
* @return tag if present, else null
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public <T extends Tag> T getUnchecked(String tagName) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return (T) this.value.get(tagName);
|
||||||
|
}
|
||||||
|
|
||||||
public @Nullable StringTag getStringTag(String tagName) {
|
public @Nullable StringTag getStringTag(String tagName) {
|
||||||
final Tag tag = this.value.get(tagName);
|
final Tag tag = this.value.get(tagName);
|
||||||
return tag instanceof StringTag ? (StringTag) tag : null;
|
return tag instanceof StringTag ? (StringTag) tag : null;
|
||||||
@ -258,12 +272,26 @@ public final class CompoundTag extends Tag implements Iterable<Entry<String, Tag
|
|||||||
* @param <T> Type of tag to remove.
|
* @param <T> Type of tag to remove.
|
||||||
* @param tagName Name of the tag to remove.
|
* @param tagName Name of the tag to remove.
|
||||||
* @return The removed tag.
|
* @return The removed tag.
|
||||||
|
* @see #removeUnchecked(String)
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public <T extends Tag> T remove(String tagName) {
|
public <T extends Tag> T remove(String tagName) {
|
||||||
return (T) this.value.remove(tagName);
|
return (T) this.value.remove(tagName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes a tag from this compound tag.
|
||||||
|
*
|
||||||
|
* @param <T> Type of tag to remove.
|
||||||
|
* @param tagName Name of the tag to remove.
|
||||||
|
* @return The removed tag.
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
public <T extends Tag> T removeUnchecked(String tagName) {
|
||||||
|
//noinspection unchecked
|
||||||
|
return (T) this.value.remove(tagName);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a set of keys in this compound tag.
|
* Gets a set of keys in this compound tag.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user