diff --git a/src/main/java/com/sk89q/jnbt/CompoundTag.java b/src/main/java/com/sk89q/jnbt/CompoundTag.java index 7550dd159..6f959e81a 100644 --- a/src/main/java/com/sk89q/jnbt/CompoundTag.java +++ b/src/main/java/com/sk89q/jnbt/CompoundTag.java @@ -196,13 +196,13 @@ public final class CompoundTag extends Tag { /** * Get a {@code int[]} named with the given key. * - *
If the key does not exist or its value is not an integer array tag, + *
If the key does not exist or its value is not an int array tag, * then an empty array will be returned.
* * @param key the key - * @return an integer array + * @return an int array */ - public int[] getIntegerArray(String key) { + public int[] getIntArray(String key) { Tag tag = value.get(key); if (tag instanceof IntArrayTag) { return ((IntArrayTag) tag).getValue(); @@ -212,15 +212,15 @@ public final class CompoundTag extends Tag { } /** - * Get an integer named with the given key. + * Get an int named with the given key. * - *If the key does not exist or its value is not an integer tag, + *
If the key does not exist or its value is not an int tag, * then {@code 0} will be returned.
* * @param key the key - * @return an integer + * @return an int */ - public int getInteger(String key) { + public int getInt(String key) { Tag tag = value.get(key); if (tag instanceof IntTag) { return ((IntTag) tag).getValue(); @@ -230,16 +230,16 @@ public final class CompoundTag extends Tag { } /** - * Get an integer named with the given key, even if it's another + * Get an int named with the given key, even if it's another * type of number. * *If the key does not exist or its value is not a number, * then {@code 0} will be returned.
* * @param key the key - * @return an integer + * @return an int */ - public int asInteger(String key) { + public int asInt(String key) { Tag tag = value.get(key); if (tag instanceof ByteTag) { return ((ByteTag) tag).getValue(); diff --git a/src/main/java/com/sk89q/jnbt/CompoundTagBuilder.java b/src/main/java/com/sk89q/jnbt/CompoundTagBuilder.java index 58a3320a2..187995a6b 100644 --- a/src/main/java/com/sk89q/jnbt/CompoundTagBuilder.java +++ b/src/main/java/com/sk89q/jnbt/CompoundTagBuilder.java @@ -62,6 +62,113 @@ public class CompoundTagBuilder { return this; } + /** + * Put the given key and value into the compound tag as a + * {@code ByteArrayTag}. + * + * @param key they key + * @param value the value + * @return this object + */ + public CompoundTagBuilder putByteArray(String key, byte[] value) { + return put(key, new ByteArrayTag(key, value)); + } + + /** + * Put the given key and value into the compound tag as a + * {@code ByteTag}. + * + * @param key they key + * @param value the value + * @return this object + */ + public CompoundTagBuilder putByte(String key, byte value) { + return put(key, new ByteTag(key, value)); + } + + /** + * Put the given key and value into the compound tag as a + * {@code DoubleTag}. + * + * @param key they key + * @param value the value + * @return this object + */ + public CompoundTagBuilder putDouble(String key, double value) { + return put(key, new DoubleTag(key, value)); + } + + /** + * Put the given key and value into the compound tag as a + * {@code FloatTag}. + * + * @param key they key + * @param value the value + * @return this object + */ + public CompoundTagBuilder putFloat(String key, float value) { + return put(key, new FloatTag(key, value)); + } + + /** + * Put the given key and value into the compound tag as a + * {@code IntArrayTag}. + * + * @param key they key + * @param value the value + * @return this object + */ + public CompoundTagBuilder putIntArray(String key, int[] value) { + return put(key, new IntArrayTag(key, value)); + } + + /** + * Put the given key and value into the compound tag as an {@code IntTag}. + * + * @param key they key + * @param value the value + * @return this object + */ + public CompoundTagBuilder putInt(String key, int value) { + return put(key, new IntTag(key, value)); + } + + /** + * Put the given key and value into the compound tag as a + * {@code LongTag}. + * + * @param key they key + * @param value the value + * @return this object + */ + public CompoundTagBuilder putLong(String key, long value) { + return put(key, new LongTag(key, value)); + } + + /** + * Put the given key and value into the compound tag as a + * {@code ShortTag}. + * + * @param key they key + * @param value the value + * @return this object + */ + public CompoundTagBuilder putShort(String key, short value) { + return put(key, new ShortTag(key, value)); + } + + /** + * Put the given key and value into the compound tag as a + * {@code StringTag}. + * + * @param key they key + * @param value the value + * @return this object + */ + public CompoundTagBuilder putString(String key, String value) { + return put(key, new StringTag(key, value)); + } + /** * Put all the entries from the given map into this map. * diff --git a/src/main/java/com/sk89q/jnbt/ListTag.java b/src/main/java/com/sk89q/jnbt/ListTag.java index 681340620..4125b43ee 100644 --- a/src/main/java/com/sk89q/jnbt/ListTag.java +++ b/src/main/java/com/sk89q/jnbt/ListTag.java @@ -210,13 +210,13 @@ public final class ListTag extends Tag { /** * Get a {@code int[]} named with the given index. * - *If the index does not exist or its value is not an integer array tag, + *
If the index does not exist or its value is not an int array tag, * then an empty array will be returned.
* * @param index the index - * @return an integer array + * @return an int array */ - public int[] getIntegerArray(int index) { + public int[] getIntArray(int index) { Tag tag = getIfExists(index); if (tag instanceof IntArrayTag) { return ((IntArrayTag) tag).getValue(); @@ -226,15 +226,15 @@ public final class ListTag extends Tag { } /** - * Get an integer named with the given index. + * Get an int named with the given index. * - *If the index does not exist or its value is not an integer tag, + *
If the index does not exist or its value is not an int tag, * then {@code 0} will be returned.
* * @param index the index - * @return an integer + * @return an int */ - public int getInteger(int index) { + public int getInt(int index) { Tag tag = getIfExists(index); if (tag instanceof IntTag) { return ((IntTag) tag).getValue(); @@ -244,16 +244,16 @@ public final class ListTag extends Tag { } /** - * Get an integer named with the given index, even if it's another + * Get an int named with the given index, even if it's another * type of number. * *If the index does not exist or its value is not a number, * then {@code 0} will be returned.
* * @param index the index - * @return an integer + * @return an int */ - public int asInteger(int index) { + public int asInt(int index) { Tag tag = getIfExists(index); if (tag instanceof ByteTag) { return ((ByteTag) tag).getValue();