mirror of https://github.com/ViaVersion/ViaNBT.git
4.2.0: More helpers, deprecate primitive setValue methods
In anticipation of value classes existing before I die of age, the primitive wrappers (and only those) will become immutable in the future.
This commit is contained in:
parent
ea616b1e44
commit
eec9aca691
2
pom.xml
2
pom.xml
|
@ -5,7 +5,7 @@
|
|||
|
||||
<groupId>com.viaversion</groupId>
|
||||
<artifactId>nbt</artifactId>
|
||||
<version>4.1.0</version>
|
||||
<version>4.2.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ViaNBT</name>
|
||||
|
|
|
@ -51,7 +51,9 @@ public class ByteTag extends NumberTag {
|
|||
* Sets the value of this tag.
|
||||
*
|
||||
* @param value New value of this tag.
|
||||
* @deprecated number tags will be immutable in the future
|
||||
*/
|
||||
@Deprecated
|
||||
public void setValue(byte value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
|
|
@ -130,6 +130,8 @@ public class CompoundTag extends Tag implements Iterable<Entry<String, Tag>> {
|
|||
|
||||
/**
|
||||
* Gets the tag.
|
||||
* <p>
|
||||
* <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 tagName Name of the tag.
|
||||
|
@ -160,8 +162,25 @@ public class CompoundTag extends Tag implements Iterable<Entry<String, Tag>> {
|
|||
return tag instanceof NumberTag ? (NumberTag) tag : null;
|
||||
}
|
||||
|
||||
public @Nullable ByteArrayTag getByteArrayTag(String tagName) {
|
||||
final Tag tag = this.value.get(tagName);
|
||||
return tag instanceof ByteArrayTag ? (ByteArrayTag) tag : null;
|
||||
}
|
||||
|
||||
public @Nullable IntArrayTag getIntArrayTag(String tagName) {
|
||||
final Tag tag = this.value.get(tagName);
|
||||
return tag instanceof IntArrayTag ? (IntArrayTag) tag : null;
|
||||
}
|
||||
|
||||
public @Nullable LongArrayTag getLongArrayTag(String tagName) {
|
||||
final Tag tag = this.value.get(tagName);
|
||||
return tag instanceof LongArrayTag ? (LongArrayTag) tag : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Puts the tag into this compound tag.
|
||||
* <p>
|
||||
* <b>This will have its generic removed and instead return a raw tag in the future.</b>
|
||||
*
|
||||
* @param <T> Type of tag to put.
|
||||
* @param tagName Name of the tag.
|
||||
|
@ -211,6 +230,8 @@ public class CompoundTag extends Tag implements Iterable<Entry<String, Tag>> {
|
|||
|
||||
/**
|
||||
* Removes a tag from this compound tag.
|
||||
* <p>
|
||||
* <b>This will have its generic removed and instead return a raw tag in the future.</b>
|
||||
*
|
||||
* @param <T> Type of tag to remove.
|
||||
* @param tagName Name of the tag to remove.
|
||||
|
|
|
@ -51,7 +51,9 @@ public class DoubleTag extends NumberTag {
|
|||
* Sets the value of this tag.
|
||||
*
|
||||
* @param value New value of this tag.
|
||||
* @deprecated number tags will be immutable in the future
|
||||
*/
|
||||
@Deprecated
|
||||
public void setValue(double value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,9 @@ public class FloatTag extends NumberTag {
|
|||
* Sets the value of this tag.
|
||||
*
|
||||
* @param value New value of this tag.
|
||||
* @deprecated number tags will be immutable in the future
|
||||
*/
|
||||
@Deprecated
|
||||
public void setValue(float value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,9 @@ public class IntTag extends NumberTag {
|
|||
* Sets the value of this tag.
|
||||
*
|
||||
* @param value New value of this tag.
|
||||
* @deprecated number tags will be immutable in the future
|
||||
*/
|
||||
@Deprecated
|
||||
public void setValue(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,9 @@ public class LongTag extends NumberTag {
|
|||
* Sets the value of this tag.
|
||||
*
|
||||
* @param value New value of this tag.
|
||||
* @deprecated number tags will be immutable in the future
|
||||
*/
|
||||
@Deprecated
|
||||
public void setValue(long value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
|
|
@ -51,7 +51,9 @@ public class ShortTag extends NumberTag {
|
|||
* Sets the value of this tag.
|
||||
*
|
||||
* @param value New value of this tag.
|
||||
* @deprecated number tags will be immutable in the future
|
||||
*/
|
||||
@Deprecated
|
||||
public void setValue(short value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ public abstract class Tag {
|
|||
|
||||
/**
|
||||
* Returns the unchecked value of this tag.
|
||||
* <p>
|
||||
* <b>The generic of this method might be removed in a later version</b>
|
||||
*
|
||||
* @param <T> expected type
|
||||
* @return unchecked value of this tag
|
||||
|
|
Loading…
Reference in New Issue