mirror of
https://github.com/ViaVersion/ViaNBT.git
synced 2025-02-17 01:21:21 +01:00
3.4.0: Add helper put methods
This commit is contained in:
parent
ad8ac024c4
commit
324eb6af2c
2
pom.xml
2
pom.xml
@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.viaversion</groupId>
|
||||
<artifactId>nbt</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<version>3.4.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ViaNBT</name>
|
||||
|
@ -112,9 +112,9 @@ public class CompoundTag extends Tag implements Iterable<Entry<String, Tag>> {
|
||||
/**
|
||||
* Puts the tag into this compound tag.
|
||||
*
|
||||
* @param <T> Type of tag to put.
|
||||
* @param <T> Type of tag to put.
|
||||
* @param tagName Name of the tag.
|
||||
* @param tag Tag to put into this compound tag.
|
||||
* @param tag Tag to put into this compound tag.
|
||||
* @return The previous tag associated with its name, or null if there wasn't one.
|
||||
*/
|
||||
@Nullable
|
||||
@ -122,6 +122,42 @@ public class CompoundTag extends Tag implements Iterable<Entry<String, Tag>> {
|
||||
return (T) this.value.put(tagName, tag);
|
||||
}
|
||||
|
||||
public void putString(String tagName, String value) {
|
||||
this.value.put(tagName, new StringTag(value));
|
||||
}
|
||||
|
||||
public void putByte(String tagName, byte value) {
|
||||
this.value.put(tagName, new ByteTag(value));
|
||||
}
|
||||
|
||||
public void putInt(String tagName, int value) {
|
||||
this.value.put(tagName, new IntTag(value));
|
||||
}
|
||||
|
||||
public void putShort(String tagName, short value) {
|
||||
this.value.put(tagName, new ShortTag(value));
|
||||
}
|
||||
|
||||
public void putLong(String tagName, long value) {
|
||||
this.value.put(tagName, new LongTag(value));
|
||||
}
|
||||
|
||||
public void putFloat(String tagName, float value) {
|
||||
this.value.put(tagName, new FloatTag(value));
|
||||
}
|
||||
|
||||
public void putDouble(String tagName, double value) {
|
||||
this.value.put(tagName, new DoubleTag(value));
|
||||
}
|
||||
|
||||
public void putBoolean(String tagName, boolean value) {
|
||||
this.value.put(tagName, new ByteTag((byte) (value ? 1 : 0)));
|
||||
}
|
||||
|
||||
public void putAll(CompoundTag compoundTag) {
|
||||
this.value.putAll(compoundTag.value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a tag from this compound tag.
|
||||
*
|
||||
|
@ -134,6 +134,10 @@ public class ListTag extends Tag implements Iterable<Tag> {
|
||||
return this.value.size();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.value.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator<Tag> iterator() {
|
||||
return this.value.iterator();
|
||||
|
Loading…
Reference in New Issue
Block a user