public override bool AddChests(IEnumerable <long> mapids, string playerid) { OpenDB(); // acquire the file this player is stored in, and the tag that represents said player string file_identifier; if (playerid == LOCAL_IDENTIFIER) { file_identifier = "~local_player"; } else { file_identifier = UuidToKey(playerid); } byte[] playerdata = BedrockDB.Get(file_identifier); if (playerdata == null) { throw new FileNotFoundException($"Player with UUID {playerid} not found"); } var file = new NbtFile(); file.BigEndian = false; file.LoadFromBuffer(playerdata, 0, playerdata.Length, NbtCompression.None); var invtag = (NbtList)file.RootTag["Inventory"]; var success = PutChestsInInventory(invtag, mapids); byte[] bytes = file.SaveToBuffer(NbtCompression.None); BedrockDB.Put(file_identifier, bytes); CloseDB(); return(success); }
private NbtFile LoadNbtFromDB(string key) { byte[] data = BedrockDB.Get(key); if (data == null) { throw new FileNotFoundException($"Key {key} not found in leveldb"); } return(LoadNbtFromBytes(data)); }