private async void TShockAPI_JistChatCommand(TShockAPI.CommandArgs args) { if (args.Parameters.Count == 0) { //TODO: Print help return; } if (args.Parameters[0].Equals("dumpenv", StringComparison.CurrentCultureIgnoreCase)) { if (Instance == null) { return; } foreach (var property in Instance.DumpGlobalEnvironment().OrderBy(i => i.Key)) { args.Player.SendInfoMessage("{0}: {1}", property.Key, property.Value.Get.HasValue == false ? "undefined" : property.Value.Get.Value.ToString()); } } else if (args.Parameters[0].Equals("dumptasks", StringComparison.CurrentCultureIgnoreCase)) { foreach (Wolfje.Plugins.Jist.stdlib.RecurringFunction recur in Instance.stdTask.DumpTasks().OrderBy(i => i.NextRunTime)) { args.Player.SendInfoMessage(recur.ToString()); } } else if (args.Parameters[0].Equals("eval", StringComparison.CurrentCultureIgnoreCase) || args.Parameters[0].Equals("ev", StringComparison.CurrentCultureIgnoreCase) && (args.Parameters.Count > 1)) { args.Player.SendInfoMessage(Instance.Eval(args.Parameters[1])); } else if (args.Parameters[0].Equals("reload", StringComparison.CurrentCultureIgnoreCase) || args.Parameters[0].Equals("rl", StringComparison.CurrentCultureIgnoreCase)) { Instance.Dispose(); Instance = null; Instance = new JistEngine(this); await Instance.LoadEngineAsync(); args.Player.SendInfoMessage("Jist reloaded"); } }
public stdalias(JistEngine engine, JistAlias aliasEngine) : base(engine) { Provides = "aliascmd"; this.engine = engine; this.aliasEngine = aliasEngine; JistPlugin.JavascriptFunctionsNeeded += JistPlugin_JavascriptFunctionsNeeded; }
public JistPlugin(Terraria.Main game) : base(game) { Order = 1; Instance = new JistEngine(this); TShockAPI.Commands.ChatCommands.Add(new TShockAPI.Command("jist.cmd", TShockAPI_JistChatCommand, "jist")); ServerApi.Hooks.GameInitialize.Register(this, game_initialize); }