/// <summary> /// Reload Config File <type> /// </summary> /// <param name="args"></param> private void CommandIReload(CommandArgs args) { if (NPCManager.CustomNPCInvasion.invasionStarted) { NPCManager.CustomNPCInvasion.StopInvasion(); } try { if (File.Exists(filepath)) { ConfigObj = new CustomNPCConfig(); ConfigObj = CustomNPCConfig.Read(filepath); return; } else { TShock.Log.ConsoleError("Config not found. Creating new one"); ConfigObj.Write(filepath); return; } } catch (Exception ex) { TShock.Log.ConsoleError(ex.Message); return; } }
private void OnInitialize(EventArgs args) { Commands.ChatCommands.Add(new Command("customnpc.spawn", CommandSpawnNPC, "csm")); Commands.ChatCommands.Add(new Command("customnpc.list", CommandListNPCS, "monsterlist", "mlist")); Commands.ChatCommands.Add(new Command("customnpc.invadereload", CommandIReload, "invadereload", "ireload")); Commands.ChatCommands.Add(new Command("customnpc.invade", CommandInvade, "monsterinvade", "minvade")); Commands.ChatCommands.Add(new Command("customnpc.info", CommandNPCInfo, "monsterinfo", "minfo")); ConfigObj = new CustomNPCConfig(); SetupConfig(); NPCManager.CustomNPCInvasion.WaveSets = ConfigObj.WaveSets; mainLoop.Elapsed += mainLoop_Elapsed; mainLoop.Enabled = true; }
/// <summary> /// Config for Custom Mob Invasions /// </summary> private void SetupConfig() { try { if (File.Exists(filepath)) { ConfigObj = new CustomNPCConfig(); ConfigObj = CustomNPCConfig.Read(filepath); return; } else { TShock.Log.ConsoleError("Config not found. Creating new one"); ConfigObj.Write(filepath); return; } } catch (Exception ex) { TShock.Log.ConsoleError(ex.Message); return; } }