Examples of NbtCompound


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

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

  @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

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

  }
 
  @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

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

  }
 
  @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

Examples of simpleserver.nbt.NBTCompound

  public String toString() {
    return String.format("%d,%d,%d", x, y, z);
  }

  public NBTCompound tag() {
    NBTCompound tag = new NBTCompound("coordinate");
    tag.put(new NBTInt("x", x));
    tag.put(new NBTInt("y", y));
    tag.put(new NBTInt("z", z));
    tag.put(new NBTInt("dimension", dimension.index()));
    return tag;
  }
View Full Code Here

Examples of simpleserver.nbt.NBTCompound

    pitch = tag.getFloat(PITCH).get();
    onGround = true;
  }

  public NBTCompound tag() {
    NBTCompound tag = new NBTCompound(POSITION);
    tag.put(new NBTDouble(X, x));
    tag.put(new NBTDouble(Y, y));
    tag.put(new NBTDouble(Z, z));
    tag.put(new NBTInt(DIMENSION, dimension.index()));
    tag.put(new NBTFloat(YAW, yaw));
    tag.put(new NBTFloat(PITCH, pitch));
    return tag;
  }
View Full Code Here

Examples of simpleserver.nbt.NBTCompound

    loadOldConfig();
  }

  private void loadChests(NBTList<NBTCompound> node) {
    for (int i = 0; i < node.size(); i++) {
      NBTCompound tag = node.get(i);
      Coordinate coord;
      try {
        coord = new Coordinate(tag.getCompound("coordinate"));
      } catch (Exception e) {
        System.out.println("Skipping corrupt chest");
        continue;
      }
      Chest chest;
      if (!tag.containsKey("owner")) {
        chest = new Chest(coord);
      } else {
        String owner = tag.getString("owner").get();
        if (!tag.containsKey("name")) {
          chest = new Chest(owner, coord);
        } else {
          chest = new Chest(owner, coord, tag.getString("name").get());
        }
      }
      locations.put(coord, chest);
    }
  }
View Full Code Here

Examples of simpleserver.nbt.NBTCompound

  }

  void save() {
    NBTList<NBTCompound> node = new NBTList<NBTCompound>(CHESTS, NBT.COMPOUND);
    for (Chest chest : locations.values()) {
      NBTCompound tag = new NBTCompound();
      tag.put(chest.coordinate.tag());
      if (!chest.isOpen()) {
        tag.put(new NBTString("owner", chest.owner.toLowerCase()));
        if (chest.name != null) {
          tag.put(new NBTString("name", chest.name));
        }
      }
      node.add(tag);
    }
    root.put(node);
View Full Code Here

Examples of simpleserver.nbt.NBTCompound

        return;
      } catch (Exception e) {
        System.out.println("[WARNING] Player list is corrupt. Replacing it with empty list...");
      }
    }
    node = new NBTCompound(PLAYERS);
    data.put(node);
    stats.loadOldConfig();
  }
View Full Code Here

Examples of simpleserver.nbt.NBTCompound

  NBTCompound get(String name) {
    name = name.toLowerCase();
    if (node.containsKey(name)) {
      return node.getCompound(name);
    } else {
      NBTCompound player = new NBTCompound(name);
      node.put(player);
      return player;
    }
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.