public TSDocs(Main game) : base(game) { Order = 1; getConfig = new TSConfig(); SavePath = Path.Combine(TShockAPI.TShock.SavePath, "TSDocs"); }
public TSDocs(Main game) : base(game) { Order = -15; getConfig = new TSConfig(); SavePath = Path.Combine(TShockAPI.TShock.SavePath, "TSDocs"); }
void OnInitialize(EventArgs e) { getConfig = new TSConfig(); try { TSConfig.Re_LoadConfig(); TSPlayer.Server.SendSuccessMessage("Loaded TSDocs Config!"); } catch (Exception ex) { TSPlayer.Server.SendErrorMessage("Error: Config failed to reload, Check logs!"); TShock.Log.Error("[TSDocs] Config Exception:"); TShock.Log.Error(ex.ToString()); } Commands.ChatCommands.Add(new Command("tsdocs.reload", TSConfig.CMDreload, "tsdocs")); Commands.ChatCommands.Add(new Command("tsdocs.news", CMDsetnews, "setnews", "snews")); Commands.ChatCommands.Add(new Command("tsdocs.news", CMDgetnews, "getnews", "gnews")); }
private static void Re_LoadConfig() { //config if (!Directory.Exists(TSDocs.SavePath)) { NewConfig(); } TSDocs.getConfig = TSConfig.Read(TSDocs.ConfigPath); TSDocs.getConfig.Write(TSDocs.ConfigPath); //motd if (TSDocs.getConfig.motd != null) { if (TSDocs.getConfig.motd.file != null) { TSUtils.CheckFile(Path.Combine(TSDocs.SavePath, TSDocs.getConfig.motd.file)); } if (TSDocs.getConfig.motd_enabled && File.ReadAllText(Path.Combine(TShock.SavePath, "motd.txt")) != "") { File.WriteAllText(Path.Combine(TShock.SavePath, "motd.txt"), ""); } if (TSDocs.getConfig.motd.groups != null) { foreach (var motd in TSDocs.getConfig.motd.groups) { TSUtils.CheckFile(Path.Combine(TSDocs.SavePath, motd.Value)); } } } //news TSUtils.CheckFile(Path.Combine(TSDocs.SavePath, TSDocs.getConfig.news_file)); //commands int i = 0; foreach (var command in TSDocs.getConfig.commands) { if (command == null) { continue; } if (command.command != null && !command.command.StartsWith("/")) { TSDocs.getConfig.commands[i].command = "/{0}".SFormat(command.command); } i++; foreach (var group in command.groups) { if (!string.IsNullOrEmpty(group.Value)) { TSUtils.CheckFile(Path.Combine(TSDocs.SavePath, group.Value)); } } if (!string.IsNullOrEmpty(command.file)) { TSUtils.CheckFile(Path.Combine(TSDocs.SavePath, command.file)); } } }