Exemple #1
0
        public string Rename(string uuid, int damage, string name)
        {
            Guid guid;

            if (!string.IsNullOrWhiteSpace(uuid) && Guid.TryParse(uuid, out guid))
            {
                Dictionary <int, NameAndLore> namesAndLore = null;

                UpdateZip(guid, (ZipFile zipFile) => {
                    namesAndLore = ReadNameAndLore(zipFile);
                    NameAndLore newNameAndLore;
                    if (namesAndLore.ContainsKey(damage))
                    {
                        newNameAndLore = new NameAndLore(damage, name, namesAndLore[damage].Lore);
                    }
                    else
                    {
                        newNameAndLore = new NameAndLore(damage, name, "");
                    }

                    namesAndLore[damage] = newNameAndLore;
                    return(UpdateType.Primary);
                });

                return("OK");
            }
            else
            {
                return("@FAILURE: uuid is not in a recognized format");
            }
        }
Exemple #2
0
        Dictionary <int, NameAndLore> ReadNameAndLore(ZipFile zipFile)
        {
            Dictionary <int, NameAndLore> result = new Dictionary <int, NameAndLore>();

            if (zipFile.ContainsEntry("names.txt"))
            {
                using (Stream stream = zipFile["names.txt"].OpenReader()) {
                    using (TextReader reader = new StreamReader(stream, Encoding.UTF8)) {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            NameAndLore nameAndLore = new NameAndLore(line);
                            result[nameAndLore.Damage] = nameAndLore;
                        }
                    }
                }
            }

            return(result);
        }