Пример #1
0
        private void WriteNbtToDB(string key, NbtFile file)
        {
            file.BigEndian = false;
            var bytes = file.SaveToBuffer(NbtCompression.None);

            BedrockDB.Put(key, bytes);
        }
Пример #2
0
        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);
        }