/// <summary> /// Gets a raw <see cref="NbtTree"/> of data for the given player. /// </summary> /// <param name="name">The name of the player to fetch.</param> /// <returns>An <see cref="NbtTree"/> containing the given player's raw data.</returns> /// <exception cref="NbtIOException">Thrown when the manager cannot read in an NBT data stream.</exception> public NbtTree GetPlayerTree(string name) { PlayerFile pf = GetPlayerFile(name); Stream nbtstr = pf.GetDataInputStream(); if (nbtstr == null) { throw new NbtIOException("Failed to initialize NBT data stream for input."); } return(new NbtTree(nbtstr)); }
public static TagNodeCompound GetPlayerData() { if (playerData == null) { string path = Path.Combine(savePath, "playerdata"); string[] files = Directory.GetFiles(path); if (files.Length == 0) { throw new Exception("no player data"); } playerFile = new PlayerFile(files[0]); playerData = new NbtTree(); playerData.ReadFrom(playerFile.GetDataInputStream()); } return(playerData.Root); }