private void AdminFileInfoPacketHandler(Packet pa) { AdminFileInfoPacket p = pa as AdminFileInfoPacket; mods.Add(new Mod { Author = p.Author, File = p.File, Name = p.ModName, Description = p.Description, BlacklistedUsers = new List <string>(p.BlacklistedUsers), WhitelistedUsers = new List <string>(p.WhitelistedUsers), PostDownloadCLI = new List <string>(p.PostDownload), Size = p.FileSize, Hash = p.Hash, Contents = new byte[p.FileSize], //This part will be filled in later. Identifier = p.Identifier, Optional = p.Optional, RequiredMods = new List <string>(p.Requires) }); if (mods.Count == mods.Capacity) { CurrentStep = ProgressStep.Connected; } }
internal void UpdateModInfo(Packet pa) { AdminFileInfoPacket p = pa as AdminFileInfoPacket; Mod m = Server.Mods.Find(new Predicate <Mod>(delegate(Mod mod) { if (mod.Identifier == p.Identifier) { return(true); } return(false); })); if (m == null) { m = new Mod(); Server.Mods.Add(m); } else if (m.ModFile != p.File) { File.Delete(Config.ModsPath + "/xml/" + Path.GetFileName(m.ModFile) + ".xml"); File.Delete(Config.ModsPath + "/" + m.ModFile); } m.Author = p.Author; m.BlacklistedUsers.Clear(); m.BlacklistedUsers.AddRange(p.BlacklistedUsers); m.Description = p.Description; m.FileSize = p.FileSize; m.ModFile = p.File; m.ModName = p.ModName; m.PostDownloadCLI = p.PostDownload; m.WhitelistedUsers.Clear(); m.WhitelistedUsers.AddRange(p.WhitelistedUsers); m.ConfigFile = Config.ModsPath + "/xml/" + Path.GetFileName(p.File) + ".xml"; m.Identifier = p.Identifier; m.Optional = p.Optional; m.RequiredMods = new List <Mod>(); foreach (Mod mod in Server.Mods) { if (p.Requires.Contains(mod.Identifier)) { m.RequiredMods.Add(mod); } } m.Save(); MinecraftModUpdater.Logger.Log(Logger.Level.Warning, "{0}({1}) has been updated by {2}", m.ModName, m.Identifier, ClientID); }