public static LoadConfigurationFromFile ( string Path ) : |
||
Path | string | |
return |
/// <summary> /// Asynchronously reparses the AliasCmd configuration file after the specified period. /// </summary> /// <param name="DelaySeconds"></param> /// <returns></returns> Task ReloadConfigAfterDelayAsync(int DelaySeconds) { return(Task.Factory.StartNew(() => { System.Threading.Thread.Sleep(DelaySeconds * 1000); TShockAPI.Log.ConsoleInfo("AliasCmd: reloading config."); try { Configuration reloadedConfig = Configuration.LoadConfigurationFromFile("tshock" + System.IO.Path.DirectorySeparatorChar + "SEconomy" + System.IO.Path.DirectorySeparatorChar + "AliasCmd.config.json"); Configuration = reloadedConfig; JScript.JScriptEngine.Initialize(); foreach (string path in System.IO.Directory.EnumerateFiles("tshock" + System.IO.Path.DirectorySeparatorChar + "SEconomy", "*.js")) { TShockAPI.Log.ConsoleInfo(string.Format("aliascmd js: loading file {0}.", path)); scriptEngine.Run(System.IO.File.ReadAllText(path)); } ParseCommands(); } catch (Exception ex) { TShockAPI.Log.ConsoleError("aliascmd: Your new config could not be loaded, fix any problems and save the file. Your old configuration is in effect until this is fixed. \r\n\r\n" + ex.ToString()); throw; } TShockAPI.Log.ConsoleInfo("AliasCmd: config reload done."); })); }
public override void Initialize() { TShockAPI.Commands.ChatCommands.Add(new TShockAPI.Command("aliascmd", ChatCommand_GeneralCommand, "aliascmd") { AllowServer = true }); JScript.JScriptEngine.Initialize(); Configuration = Configuration.LoadConfigurationFromFile("tshock" + System.IO.Path.DirectorySeparatorChar + "SEconomy" + System.IO.Path.DirectorySeparatorChar + "AliasCmd.config.json"); foreach (string path in System.IO.Directory.EnumerateFiles("tshock" + System.IO.Path.DirectorySeparatorChar + "SEconomy", "*.js")) { TShockAPI.Log.ConsoleInfo(string.Format("aliascmd js: loading file {0}.", path)); scriptEngine.Run(System.IO.File.ReadAllText(path)); } ParseCommands(); }