Package com.comphenix.protocol.wrappers.nbt

Examples of com.comphenix.protocol.wrappers.nbt.NbtCompound


          list.getValue().add(base);
        }
        return (NbtWrapper<?>) list;
     
      } else {
        NbtCompound compound = NbtFactory.ofCompound(decoded[0]);
        ConfigurationSection section = (ConfigurationSection) node;
       
        // As above
        for (String key : section.getKeys(false))
          compound.put(readNode(section, key));
        return (NbtWrapper<?>) compound;
      }
     
    } else {
      // We need to know
View Full Code Here


  @Test
  public void testGetNbtModifier() {
    PacketContainer updateTileEntity = new PacketContainer(PacketType.Play.Server.TILE_ENTITY_DATA);
   
    NbtCompound compound = NbtFactory.ofCompound("test");
    compound.put("test", "name");
    compound.put(NbtFactory.ofList("ages", 1, 2, 3));
   
    updateTileEntity.getNbtModifier().write(0, compound);
   
    NbtCompound result = (NbtCompound) updateTileEntity.getNbtModifier().read(0);
   
    assertEquals(compound.getString("test"), result.getString("test"));
    assertEquals(compound.getList("ages"), result.getList("ages"));
  }
View Full Code Here

  }
 
  @SuppressWarnings("unchecked")
  @Test
  public void testSerialization() {
    NbtCompound compound = NbtFactory.ofCompound("hello");
    compound.put("age", (short) 30);
    compound.put("name", "test");
    compound.put("values", new int[] { 1, 2, 3});
    compound.put(NbtFactory.ofList("telephone", "12345678", "81549300"));
   
    compound.put(NbtFactory.ofList("lists", NbtFactory.ofList("", "a", "a", "b", "c")));
   
    YamlConfiguration yaml = new YamlConfiguration();
    NbtConfigurationSerializer.DEFAULT.serialize(compound, yaml);
   
    NbtCompound result = NbtConfigurationSerializer.DEFAULT.deserializeCompound(yaml, "hello");
   
    assertEquals(compound, result);
  }
View Full Code Here

  }
 
  @Test
  public void testCompound() throws IOException {
    StreamSerializer serializer = new StreamSerializer();
    NbtCompound initial = NbtFactory.ofCompound("tag");
    initial.put("name", "Ole");
    initial.put("age", 20);
   
    // Buffer
    ByteArrayOutputStream buffer = new ByteArrayOutputStream();
    serializer.serializeCompound(new DataOutputStream(buffer), initial);
   
    DataInputStream input = new DataInputStream(
        new ByteArrayInputStream(buffer.toByteArray()));
    NbtCompound deserialized = serializer.deserializeCompound(input);
   
    assertEquals(initial, deserialized);
  }
View Full Code Here

TOP

Related Classes of com.comphenix.protocol.wrappers.nbt.NbtCompound

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.