#3803: Add NBT module

This commit is contained in:
Outfluencer
2025-05-31 10:16:29 +10:00
committed by md_5
parent bec329352d
commit 41e49dad6b
39 changed files with 1514 additions and 154 deletions

View File

@@ -40,6 +40,12 @@
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-nbt</artifactId>
<version>${project.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
@@ -51,11 +57,5 @@
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>se.llbit</groupId>
<artifactId>jo-nbt</artifactId>
<version>1.3.0</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@@ -21,10 +21,11 @@ import java.util.function.BiConsumer;
import lombok.RequiredArgsConstructor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ComponentStyle;
import se.llbit.nbt.ErrorTag;
import se.llbit.nbt.NamedTag;
import se.llbit.nbt.SpecificTag;
import se.llbit.nbt.Tag;
import net.md_5.bungee.nbt.NamedTag;
import net.md_5.bungee.nbt.Tag;
import net.md_5.bungee.nbt.TypedTag;
import net.md_5.bungee.nbt.limit.NBTLimiter;
import net.md_5.bungee.nbt.type.EndTag;
@RequiredArgsConstructor
public abstract class DefinedPacket
@@ -116,7 +117,7 @@ public abstract class DefinedPacket
{
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_3 )
{
SpecificTag nbt = (SpecificTag) readTag( buf, protocolVersion );
TypedTag nbt = (TypedTag) readTag( buf, protocolVersion );
JsonElement json = TagUtil.toJson( nbt );
return ChatSerializer.forVersion( protocolVersion ).deserialize( json );
@@ -130,7 +131,7 @@ public abstract class DefinedPacket
public static ComponentStyle readComponentStyle(ByteBuf buf, int protocolVersion)
{
SpecificTag nbt = (SpecificTag) readTag( buf, protocolVersion );
TypedTag nbt = (TypedTag) readTag( buf, protocolVersion );
JsonElement json = TagUtil.toJson( nbt );
return ChatSerializer.forVersion( protocolVersion ).deserializeStyle( json );
@@ -152,8 +153,7 @@ public abstract class DefinedPacket
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_3 )
{
JsonElement json = ChatSerializer.forVersion( protocolVersion ).toJson( message );
SpecificTag nbt = TagUtil.fromJson( json );
TypedTag nbt = TagUtil.fromJson( json );
writeTag( nbt, buf, protocolVersion );
} else
{
@@ -166,8 +166,7 @@ public abstract class DefinedPacket
public static void writeComponentStyle(ComponentStyle style, ByteBuf buf, int protocolVersion)
{
JsonElement json = ChatSerializer.forVersion( protocolVersion ).toJson( style );
SpecificTag nbt = TagUtil.fromJson( json );
TypedTag nbt = TagUtil.fromJson( json );
writeTag( nbt, buf, protocolVersion );
}
@@ -456,29 +455,26 @@ public abstract class DefinedPacket
public static Tag readTag(ByteBuf input, int protocolVersion)
{
DataInputStream in = new DataInputStream( new ByteBufInputStream( input ) );
Tag tag;
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
try
{
try
if ( protocolVersion >= ProtocolConstants.MINECRAFT_1_20_2 )
{
byte type = in.readByte();
if ( type == 0 )
{
return Tag.END;
return EndTag.INSTANCE;
} else
{
tag = SpecificTag.read( type, in );
return Tag.readById( type, in, new NBTLimiter( 1 << 21 ) );
}
} catch ( IOException ex )
{
tag = new ErrorTag( "IOException while reading tag type:\n" + ex.getMessage() );
}
} else
NamedTag namedTag = new NamedTag();
namedTag.read( in, new NBTLimiter( 1 << 21 ) );
return namedTag;
} catch ( IOException ex )
{
tag = NamedTag.read( in );
throw new RuntimeException( "Exception reading tag", ex );
}
Preconditions.checkArgument( !tag.isError(), "Error reading tag: %s", tag.error() );
return tag;
}
public static void writeTag(Tag tag, ByteBuf output, int protocolVersion)
@@ -486,11 +482,11 @@ public abstract class DefinedPacket
DataOutputStream out = new DataOutputStream( new ByteBufOutputStream( output ) );
try
{
if ( tag instanceof SpecificTag )
if ( tag instanceof TypedTag )
{
SpecificTag specificTag = (SpecificTag) tag;
specificTag.writeType( out );
specificTag.write( out );
TypedTag typedTag = (TypedTag) tag;
out.writeByte( typedTag.getId() );
typedTag.write( out );
} else
{
tag.write( out );

View File

@@ -7,31 +7,32 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import se.llbit.nbt.ByteArrayTag;
import se.llbit.nbt.ByteTag;
import se.llbit.nbt.CompoundTag;
import se.llbit.nbt.DoubleTag;
import se.llbit.nbt.FloatTag;
import se.llbit.nbt.IntArrayTag;
import se.llbit.nbt.IntTag;
import se.llbit.nbt.ListTag;
import se.llbit.nbt.LongArrayTag;
import se.llbit.nbt.LongTag;
import se.llbit.nbt.NamedTag;
import se.llbit.nbt.ShortTag;
import se.llbit.nbt.SpecificTag;
import se.llbit.nbt.StringTag;
import se.llbit.nbt.Tag;
import net.md_5.bungee.nbt.Tag;
import net.md_5.bungee.nbt.TypedTag;
import net.md_5.bungee.nbt.type.ByteArrayTag;
import net.md_5.bungee.nbt.type.ByteTag;
import net.md_5.bungee.nbt.type.CompoundTag;
import net.md_5.bungee.nbt.type.DoubleTag;
import net.md_5.bungee.nbt.type.EndTag;
import net.md_5.bungee.nbt.type.FloatTag;
import net.md_5.bungee.nbt.type.IntArrayTag;
import net.md_5.bungee.nbt.type.IntTag;
import net.md_5.bungee.nbt.type.ListTag;
import net.md_5.bungee.nbt.type.LongArrayTag;
import net.md_5.bungee.nbt.type.LongTag;
import net.md_5.bungee.nbt.type.ShortTag;
import net.md_5.bungee.nbt.type.StringTag;
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class TagUtil
{
public static SpecificTag fromJson(JsonElement json)
public static TypedTag fromJson(JsonElement json)
{
if ( json instanceof JsonPrimitive )
{
@@ -64,17 +65,17 @@ public final class TagUtil
return new StringTag( jsonPrimitive.getAsString() );
} else if ( jsonPrimitive.isBoolean() )
{
return new ByteTag( jsonPrimitive.getAsBoolean() ? 1 : 0 );
return new ByteTag( (byte) ( jsonPrimitive.getAsBoolean() ? 1 : 0 ) );
} else
{
throw new IllegalArgumentException( "Unknown JSON primitive: " + jsonPrimitive );
}
} else if ( json instanceof JsonObject )
{
CompoundTag compoundTag = new CompoundTag();
CompoundTag compoundTag = new CompoundTag( new LinkedHashMap<>() );
for ( Map.Entry<String, JsonElement> property : ( (JsonObject) json ).entrySet() )
{
compoundTag.add( property.getKey(), fromJson( property.getValue() ) );
compoundTag.getValue().put( property.getKey(), fromJson( property.getValue() ) );
}
return compoundTag;
@@ -82,103 +83,103 @@ public final class TagUtil
{
List<JsonElement> jsonArray = ( (JsonArray) json ).asList();
Integer listType = null;
Byte listType = null;
for ( JsonElement jsonEl : jsonArray )
{
int type = fromJson( jsonEl ).tagType();
byte type = fromJson( jsonEl ).getId();
if ( listType == null )
{
listType = type;
} else if ( listType != type )
{
listType = Tag.TAG_COMPOUND;
listType = Tag.COMPOUND;
break;
}
}
if ( listType == null )
{
return new ListTag( Tag.TAG_END, Collections.emptyList() );
return new ListTag( Collections.emptyList(), Tag.END );
}
SpecificTag listTag;
TypedTag listTag;
switch ( listType )
{
case Tag.TAG_BYTE:
case Tag.BYTE:
byte[] bytes = new byte[ jsonArray.size() ];
for ( int i = 0; i < bytes.length; i++ )
{
bytes[i] = (Byte) ( (JsonPrimitive) jsonArray.get( i ) ).getAsNumber();
bytes[i] = (Byte) ( jsonArray.get( i ) ).getAsNumber();
}
listTag = new ByteArrayTag( bytes );
break;
case Tag.TAG_INT:
case Tag.INT:
int[] ints = new int[ jsonArray.size() ];
for ( int i = 0; i < ints.length; i++ )
{
ints[i] = (Integer) ( (JsonPrimitive) jsonArray.get( i ) ).getAsNumber();
ints[i] = (Integer) ( jsonArray.get( i ) ).getAsNumber();
}
listTag = new IntArrayTag( ints );
break;
case Tag.TAG_LONG:
case Tag.LONG:
long[] longs = new long[ jsonArray.size() ];
for ( int i = 0; i < longs.length; i++ )
{
longs[i] = (Long) ( (JsonPrimitive) jsonArray.get( i ) ).getAsNumber();
longs[i] = (Long) ( jsonArray.get( i ) ).getAsNumber();
}
listTag = new LongArrayTag( longs );
break;
default:
List<SpecificTag> tagItems = new ArrayList<>( jsonArray.size() );
List<TypedTag> tagItems = new ArrayList<>( jsonArray.size() );
for ( JsonElement jsonEl : jsonArray )
{
SpecificTag subTag = fromJson( jsonEl );
if ( listType == Tag.TAG_COMPOUND && !( subTag instanceof CompoundTag ) )
TypedTag subTag = fromJson( jsonEl );
if ( listType == Tag.COMPOUND && !( subTag instanceof CompoundTag ) )
{
CompoundTag wrapper = new CompoundTag();
wrapper.add( "", subTag );
CompoundTag wrapper = new CompoundTag( new LinkedHashMap<>() );
wrapper.getValue().put( "", subTag );
subTag = wrapper;
}
tagItems.add( subTag );
}
listTag = new ListTag( listType, tagItems );
listTag = new ListTag( tagItems, listType );
break;
}
return listTag;
} else if ( json instanceof JsonNull )
{
return Tag.END;
return EndTag.INSTANCE;
}
throw new IllegalArgumentException( "Unknown JSON element: " + json );
}
public static JsonElement toJson(SpecificTag tag)
public static JsonElement toJson(TypedTag tag)
{
switch ( tag.tagType() )
switch ( tag.getId() )
{
case Tag.TAG_BYTE:
return new JsonPrimitive( (byte) ( (ByteTag) tag ).getData() );
case Tag.TAG_SHORT:
return new JsonPrimitive( ( (ShortTag) tag ).getData() );
case Tag.TAG_INT:
return new JsonPrimitive( ( (IntTag) tag ).getData() );
case Tag.TAG_LONG:
return new JsonPrimitive( ( (LongTag) tag ).getData() );
case Tag.TAG_FLOAT:
return new JsonPrimitive( ( (FloatTag) tag ).getData() );
case Tag.TAG_DOUBLE:
return new JsonPrimitive( ( (DoubleTag) tag ).getData() );
case Tag.TAG_BYTE_ARRAY:
byte[] byteArray = ( (ByteArrayTag) tag ).getData();
case Tag.BYTE:
return new JsonPrimitive( ( (ByteTag) tag ).getValue() );
case Tag.SHORT:
return new JsonPrimitive( ( (ShortTag) tag ).getValue() );
case Tag.INT:
return new JsonPrimitive( ( (IntTag) tag ).getValue() );
case Tag.LONG:
return new JsonPrimitive( ( (LongTag) tag ).getValue() );
case Tag.FLOAT:
return new JsonPrimitive( ( (FloatTag) tag ).getValue() );
case Tag.DOUBLE:
return new JsonPrimitive( ( (DoubleTag) tag ).getValue() );
case Tag.BYTE_ARRAY:
byte[] byteArray = ( (ByteArrayTag) tag ).getValue();
JsonArray jsonByteArray = new JsonArray( byteArray.length );
for ( byte b : byteArray )
@@ -187,21 +188,21 @@ public final class TagUtil
}
return jsonByteArray;
case Tag.TAG_STRING:
return new JsonPrimitive( ( (StringTag) tag ).getData() );
case Tag.TAG_LIST:
List<SpecificTag> items = ( (ListTag) tag ).items;
case Tag.STRING:
return new JsonPrimitive( ( (StringTag) tag ).getValue() );
case Tag.LIST:
List<TypedTag> items = ( (ListTag) tag ).getValue();
JsonArray jsonList = new JsonArray( items.size() );
for ( SpecificTag subTag : items )
for ( TypedTag subTag : items )
{
if ( subTag instanceof CompoundTag )
{
CompoundTag compound = (CompoundTag) subTag;
if ( compound.size() == 1 )
if ( compound.getValue().size() == 1 )
{
SpecificTag first = (SpecificTag) compound.get( "" );
if ( !first.isError() )
TypedTag first = compound.getValue().get( "" );
if ( first != null )
{
jsonList.add( toJson( first ) );
continue;
@@ -213,16 +214,13 @@ public final class TagUtil
}
return jsonList;
case Tag.TAG_COMPOUND:
case Tag.COMPOUND:
JsonObject jsonObject = new JsonObject();
for ( NamedTag subTag : (CompoundTag) tag )
{
jsonObject.add( subTag.name(), toJson( subTag.getTag() ) );
}
CompoundTag compoundTag = (CompoundTag) tag;
compoundTag.getValue().forEach( (key, value) -> jsonObject.add( key, toJson( value ) ) );
return jsonObject;
case Tag.TAG_INT_ARRAY:
int[] intArray = ( (IntArrayTag) tag ).getData();
case Tag.INT_ARRAY:
int[] intArray = ( (IntArrayTag) tag ).getValue();
JsonArray jsonIntArray = new JsonArray( intArray.length );
for ( int i : intArray )
@@ -231,8 +229,8 @@ public final class TagUtil
}
return jsonIntArray;
case Tag.TAG_LONG_ARRAY:
long[] longArray = ( (LongArrayTag) tag ).getData();
case Tag.LONG_ARRAY:
long[] longArray = ( (LongArrayTag) tag ).getValue();
JsonArray jsonLongArray = new JsonArray( longArray.length );
for ( long l : longArray )

View File

@@ -5,11 +5,11 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import net.md_5.bungee.nbt.TypedTag;
import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.Protocol;
import net.md_5.bungee.protocol.ProtocolConstants;
import se.llbit.nbt.Tag;
@Data
@NoArgsConstructor
@@ -19,13 +19,13 @@ public class CustomClickAction extends DefinedPacket
{
private String id;
private Tag data;
private TypedTag data;
@Override
public void read(ByteBuf buf, Protocol protocol, ProtocolConstants.Direction direction, int protocolVersion)
{
id = readString( buf );
data = readNullable( (buf0) -> readTag( buf0, protocolVersion ), buf );
data = readNullable( (buf0) -> (TypedTag) readTag( buf0, protocolVersion ), buf );
}
@Override

View File

@@ -7,11 +7,11 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import net.md_5.bungee.nbt.Tag;
import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.Location;
import net.md_5.bungee.protocol.ProtocolConstants;
import se.llbit.nbt.Tag;
@Data
@NoArgsConstructor

View File

@@ -5,11 +5,11 @@ import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import net.md_5.bungee.nbt.Tag;
import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.Location;
import net.md_5.bungee.protocol.ProtocolConstants;
import se.llbit.nbt.Tag;
@Data
@NoArgsConstructor

View File

@@ -7,13 +7,13 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import net.md_5.bungee.api.dialog.Dialog;
import net.md_5.bungee.nbt.TypedTag;
import net.md_5.bungee.protocol.AbstractPacketHandler;
import net.md_5.bungee.protocol.ChatSerializer;
import net.md_5.bungee.protocol.DefinedPacket;
import net.md_5.bungee.protocol.Either;
import net.md_5.bungee.protocol.ProtocolConstants;
import net.md_5.bungee.protocol.TagUtil;
import se.llbit.nbt.SpecificTag;
@Data
@NoArgsConstructor
@@ -39,7 +39,7 @@ public class ShowDialog extends DefinedPacket
protected static Dialog readDialog(ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
SpecificTag nbt = (SpecificTag) readTag( buf, protocolVersion );
TypedTag nbt = (TypedTag) readTag( buf, protocolVersion );
JsonElement json = TagUtil.toJson( nbt );
return ChatSerializer.forVersion( protocolVersion ).getDialogSerializer().deserialize( json );
}
@@ -60,7 +60,7 @@ public class ShowDialog extends DefinedPacket
protected static void writeDialog(Dialog dialog, ByteBuf buf, ProtocolConstants.Direction direction, int protocolVersion)
{
JsonElement json = ChatSerializer.forVersion( protocolVersion ).getDialogSerializer().toJson( dialog );
SpecificTag nbt = TagUtil.fromJson( json );
TypedTag nbt = TagUtil.fromJson( json );
writeTag( nbt, buf, protocolVersion );
}

View File

@@ -6,16 +6,16 @@ import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonPrimitive;
import net.md_5.bungee.nbt.Tag;
import net.md_5.bungee.nbt.TypedTag;
import net.md_5.bungee.nbt.type.ByteArrayTag;
import net.md_5.bungee.nbt.type.CompoundTag;
import net.md_5.bungee.nbt.type.IntArrayTag;
import net.md_5.bungee.nbt.type.IntTag;
import net.md_5.bungee.nbt.type.ListTag;
import net.md_5.bungee.nbt.type.LongArrayTag;
import net.md_5.bungee.nbt.type.StringTag;
import org.junit.jupiter.api.Test;
import se.llbit.nbt.ByteArrayTag;
import se.llbit.nbt.CompoundTag;
import se.llbit.nbt.IntArrayTag;
import se.llbit.nbt.IntTag;
import se.llbit.nbt.ListTag;
import se.llbit.nbt.LongArrayTag;
import se.llbit.nbt.SpecificTag;
import se.llbit.nbt.StringTag;
import se.llbit.nbt.Tag;
public class TagUtilTest
{
@@ -25,7 +25,7 @@ public class TagUtilTest
private static void testDissembleReassemble(String json)
{
JsonElement parsedJson = GSON.fromJson( json, JsonElement.class );
SpecificTag nbt = TagUtil.fromJson( parsedJson );
TypedTag nbt = TagUtil.fromJson( parsedJson );
JsonElement convertedElement = TagUtil.toJson( nbt );
String convertedJson = GSON.toJson( convertedElement );
@@ -35,18 +35,19 @@ public class TagUtilTest
@Test
public void testStringLiteral()
{
// this test only passes if the CompoundTags are backed by a LinkedHashMap
testDissembleReassemble( "{\"text\":\"\",\"extra\":[\"hello\",{\"text\":\"there\",\"color\":\"#ff0000\"},{\"text\":\"friend\",\"font\":\"minecraft:default\"}]}" );
}
public void testCreateMixedList(JsonArray array)
{
SpecificTag tag = TagUtil.fromJson( array );
TypedTag tag = TagUtil.fromJson( array );
assertInstanceOf( ListTag.class, tag );
ListTag list = (ListTag) tag;
assertEquals( SpecificTag.TAG_COMPOUND, list.getType() );
assertEquals( array.size(), list.size() );
assertEquals( Tag.COMPOUND, list.getListType() );
assertEquals( array.size(), list.getValue().size() );
for ( int i = 0; i < list.size(); i++ )
for ( int i = 0; i < list.getValue().size(); i++ )
{
assertTrue( i < array.size() );
@@ -77,7 +78,7 @@ public class TagUtilTest
assertInstanceOf( IntTag.class, value );
IntTag integer = (IntTag) value;
assertEquals( array.get( i ).getAsInt(), integer.getData() );
assertEquals( array.get( i ).getAsInt(), integer.getValue() );
}
} else if ( primitive.isString() )
@@ -85,7 +86,7 @@ public class TagUtilTest
assertInstanceOf( StringTag.class, value );
StringTag string = (StringTag) value;
assertEquals( array.get( i ).getAsString(), string.getData() );
assertEquals( array.get( i ).getAsString(), string.getValue() );
}
}
}
@@ -129,11 +130,11 @@ public class TagUtilTest
public void testCreateEmptyList()
{
JsonArray array = new JsonArray();
SpecificTag tag = TagUtil.fromJson( array );
TypedTag tag = TagUtil.fromJson( array );
assertInstanceOf( ListTag.class, tag );
ListTag list = (ListTag) tag;
assertEquals( 0, list.size() );
assertEquals( Tag.TAG_END, list.getType() );
assertEquals( Tag.END, list.getListType() );
}
@Test
@@ -143,16 +144,16 @@ public class TagUtilTest
array.add( ( (byte) 1 ) );
array.add( ( (byte) 2 ) );
SpecificTag tag = TagUtil.fromJson( array );
TypedTag tag = TagUtil.fromJson( array );
assertInstanceOf( ByteArrayTag.class, tag );
ByteArrayTag byteArray = (ByteArrayTag) tag;
assertEquals( 2, byteArray.getData().length );
assertEquals( 2, byteArray.getValue().length );
for ( int i = 0; i < byteArray.getData().length; i++ )
for ( int i = 0; i < byteArray.getValue().length; i++ )
{
assertTrue( i < array.size() );
byte item = byteArray.getData()[i];
byte item = byteArray.getValue()[i];
assertEquals( array.get( i ).getAsByte(), item );
}
}
@@ -164,16 +165,16 @@ public class TagUtilTest
array.add( 1 );
array.add( 2 );
SpecificTag tag = TagUtil.fromJson( array );
TypedTag tag = TagUtil.fromJson( array );
assertInstanceOf( IntArrayTag.class, tag );
IntArrayTag intArray = (IntArrayTag) tag;
assertEquals( 2, intArray.getData().length );
assertEquals( 2, intArray.getValue().length );
for ( int i = 0; i < intArray.getData().length; i++ )
for ( int i = 0; i < intArray.getValue().length; i++ )
{
assertTrue( i < array.size() );
int item = intArray.getData()[i];
int item = intArray.getValue()[i];
assertEquals( array.get( i ).getAsInt(), item );
}
}
@@ -185,16 +186,16 @@ public class TagUtilTest
array.add( 1L );
array.add( 2L );
SpecificTag tag = TagUtil.fromJson( array );
TypedTag tag = TagUtil.fromJson( array );
assertInstanceOf( LongArrayTag.class, tag );
LongArrayTag intArray = (LongArrayTag) tag;
assertEquals( 2, intArray.getData().length );
assertEquals( 2, intArray.getValue().length );
for ( int i = 0; i < intArray.getData().length; i++ )
for ( int i = 0; i < intArray.getValue().length; i++ )
{
assertTrue( i < array.size() );
long item = intArray.getData()[i];
long item = intArray.getValue()[i];
assertEquals( array.get( i ).getAsLong(), item );
}
}
@@ -206,10 +207,10 @@ public class TagUtilTest
array.add( "a" );
array.add( "b" );
SpecificTag tag = TagUtil.fromJson( array );
TypedTag tag = TagUtil.fromJson( array );
assertInstanceOf( ListTag.class, tag );
ListTag list = (ListTag) tag;
assertEquals( SpecificTag.TAG_STRING, list.getType() );
assertEquals( Tag.STRING, list.getListType() );
assertEquals( 2, list.size() );
for ( int i = 0; i < list.size(); i++ )
@@ -220,7 +221,7 @@ public class TagUtilTest
assertInstanceOf( StringTag.class, item );
StringTag string = (StringTag) item;
assertEquals( array.get( i ).getAsString(), string.getData() );
assertEquals( array.get( i ).getAsString(), string.getValue() );
}
}
}