public override void Load(string code) { Engine = new JintEngine(Options.Ecmascript5) .AllowClr(true); Engine.SetParameter("Commands", chatCommands) .SetParameter("DataStore", DataStore.GetInstance()) .SetParameter("Find", Find.GetInstance()) .SetParameter("GlobalData", GlobalData) .SetParameter("Plugin", this) .SetParameter("Server", Server.GetInstance()) .SetParameter("ServerConsoleCommands", consoleCommands) .SetParameter("Util", Util.GetInstance()) .SetParameter("Web", Web) .SetParameter("World", World.GetInstance()) .SetFunction("importClass", new importit(importClass)); try { Program = JintEngine.Compile(code, false); Globals = (from statement in Program.Statements where statement.GetType() == typeof(FunctionDeclarationStatement) select((FunctionDeclarationStatement)statement).Name).ToList <string>(); Engine.Run(Program); State = PluginState.Loaded; } catch (Exception ex) { Logger.LogException(ex); State = PluginState.FailedToLoad; } PluginLoader.GetInstance().OnPluginLoaded(this); }
public override void Load(string code = "") { try { Engine = new JintEngine(Options.Ecmascript5) .AllowClr(true); Engine.SetParameter("Plugin", this) .SetParameter("Server", Fougerite.Server.GetServer()) .SetParameter("DataStore", DataStore.GetInstance()) .SetParameter("Data", Data.GetData()) .SetParameter("Web", new Fougerite.Web()) .SetParameter("Util", Util.GetUtil()) .SetParameter("World", World.GetWorld()) #pragma warning disable 618 .SetParameter("PluginCollector", GlobalPluginCollector.GetPluginCollector()) #pragma warning restore 618 .SetParameter("Loom", Fougerite.Loom.Current) .SetParameter("JSON", Fougerite.JsonAPI.GetInstance) .SetParameter("MySQL", Fougerite.MySQLConnector.GetInstance) .SetParameter("SQLite", Fougerite.SQLiteConnector.GetInstance) .SetFunction("importClass", new importit(importClass)); Program = JintEngine.Compile(code, false); Globals = (from statement in Program.Statements where statement.GetType() == typeof(FunctionDeclarationStatement) select((FunctionDeclarationStatement)statement).Name).ToList <string>(); Engine.Run(Program); object author = GetGlobalObject("Author"); object about = GetGlobalObject("About"); object version = GetGlobalObject("Version"); Author = author == null || (string)author == "undefined" ? "Unknown" : author.ToString(); About = about == null || (string)about == "undefined" ? "" : about.ToString(); Version = version == null || (string)version == "undefined" ? "1.0" : version.ToString(); State = PluginState.Loaded; } catch (Exception ex) { Logger.LogError("[Error] Failed to load lua plugin: " + ex); State = PluginState.FailedToLoad; PluginLoader.GetInstance().CurrentlyLoadingPlugins.Remove(Name); } PluginLoader.GetInstance().OnPluginLoaded(this); }
public override void Load(string code = "") { try { Engine = new JintEngine(Options.Ecmascript5) .AllowClr(true); Engine.SetParameter("Commands", chatCommands) .SetParameter("DataStore", DataStore.GetInstance()) .SetParameter("Find", Find.GetInstance()) .SetParameter("GlobalData", GlobalData) .SetParameter("Plugin", this) .SetParameter("Server", Server.GetInstance()) .SetParameter("ServerConsoleCommands", consoleCommands) .SetParameter("Util", Util.GetInstance()) .SetParameter("Web", Web) .SetParameter("World", World.GetInstance()) .SetFunction("importClass", new importit(importClass)); Program = JintEngine.Compile(code, false); Globals = (from statement in Program.Statements where statement.GetType() == typeof(FunctionDeclarationStatement) select ((FunctionDeclarationStatement)statement).Name).ToList<string>(); Engine.Run(Program); object author = GetGlobalObject("Author"); object about = GetGlobalObject("About"); object version = GetGlobalObject("Version"); Author = author == null ? "" : author.ToString(); About = about == null ? "" : about.ToString(); Version = version == null ? "" : version.ToString(); State = PluginState.Loaded; } catch (Exception ex) { Logger.LogException(ex); State = PluginState.FailedToLoad; PluginLoader.GetInstance().CurrentlyLoadingPlugins.Remove(Name); } PluginLoader.GetInstance().OnPluginLoaded(this); }
public override void Load(string code = "") { try { Engine = new JintEngine(Options.Ecmascript5) .AllowClr(true); Engine.SetParameter("Commands", chatCommands) .SetParameter("DataStore", DataStore.GetInstance()) .SetParameter("Find", Find.GetInstance()) .SetParameter("GlobalData", GlobalData) .SetParameter("Plugin", this) .SetParameter("Server", Server.GetInstance()) .SetParameter("ServerConsoleCommands", consoleCommands) .SetParameter("Util", Util.GetInstance()) .SetParameter("Web", Web) .SetParameter("World", World.GetInstance()) .SetFunction("importClass", new importit(importClass)); Program = JintEngine.Compile(code, false); Globals = (from statement in Program.Statements where statement.GetType() == typeof(FunctionDeclarationStatement) select((FunctionDeclarationStatement)statement).Name).ToList <string>(); Engine.Run(Program); object author = GetGlobalObject("Author"); object about = GetGlobalObject("About"); object version = GetGlobalObject("Version"); Author = author == null ? "" : author.ToString(); About = about == null ? "" : about.ToString(); Version = version == null ? "" : version.ToString(); State = PluginState.Loaded; } catch (Exception ex) { Logger.LogException(ex); State = PluginState.FailedToLoad; PluginLoader.GetInstance().CurrentlyLoadingPlugins.Remove(Name); } PluginLoader.GetInstance().OnPluginLoaded(this); }
public static bool IsJavaScript(string Text) { string TrimmedText = Text.Trim(); if (TrimmedText.StartsWith("<") || TrimmedText.StartsWith("{") || TrimmedText.StartsWith("[") || TrimmedText.EndsWith(">")) { return(false); } if (!(TrimmedText.Contains("=") || TrimmedText.Contains(";") || TrimmedText.Contains("(") || TrimmedText.Contains(")"))) { return(false); } try { Jint.Expressions.Program Prog = JintEngine.Compile(Text, false); if (Prog.Statements.Count == 0) { return(false); } } catch { return(false); } return(true); }