Package simpleserver.nbt

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


    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

    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

  }

  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

        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

  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

  public Set<String> names() {
    return node.names();
  }

  public String getRealName(String playerName) {
    NBTCompound playerData = get(playerName.toLowerCase());
    String field = PlayerField.FULL_NAME.toString();
    if (playerData.containsKey(field)) {
      return playerData.getString(field).get();
    } else {
      NBTString tag = new NBTString(field, playerName);
      playerData.put(tag);
      return tag.get();
    }
  }
View Full Code Here

      return tag.get();
    }
  }

  public String getRenameName(String playerName) {
    NBTCompound playerData = get(playerName.toLowerCase());
    String field = PlayerField.RENAME_NAME.toString();
    if (playerData.containsKey(field)) {
      return playerData.getString(field).get();
    } else {
      NBTString tag = new NBTString(field, playerName);
      playerData.put(tag);
      return tag.get();
    }
  }
View Full Code Here

      return tag.get();
    }
  }

  public byte[] getPwHash(String playerName) {
    NBTCompound playerData = get(playerName.toLowerCase());
    String field = PlayerField.PW_HASH.toString();
    if (playerData.containsKey(field)) {
      byte[] a = playerData.getArray(field).get();
      return a;
    }
    return null;
  }
View Full Code Here

    }
    return null;
  }

  public void setRealName(String realName) {
    NBTCompound playerData = get(realName.toLowerCase());
    String field = PlayerField.FULL_NAME.toString();
    if (playerData.containsKey(field)) {
      playerData.getString(field).set(realName);
    } else {
      NBTString tag = new NBTString(field, realName);
      playerData.put(tag);
    }
  }
View Full Code Here

TOP

Related Classes of simpleserver.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.