static void Main(string[] args) { StockcurrentTimeMillis(); Logger.Init(); StartTime = Environment.TickCount; Settings.Initialize(); Logger.Info("Settings loaded !"); Logger.Stage("Database"); DatabaseManager.Initialize(); DatabaseCache.Initialize(); Logger.Stage("Plugins"); AdminCommandManager.Initialize(); PlayerCommandManager.Initialize(); ScriptKernel.Load(); JSKernel.Load(); Logger.Stage("Network"); Network.InterClient.Initialize(); Network.WorldServer.Initialize(); Logger.Info("Tera started in " + (Environment.TickCount - StartTime) + "ms"); while (true) { Console.ReadLine(); } }
private static void ProcessBasicConsoleRequest(WorldClient Client, String packet) { if (Client.Account.Level > 0) { var data = packet.Substring(2).Split(' '); var parameters = new CommandParameters(data); var command = AdminCommandManager.GetCommand(parameters.Prefix.ToLower()); if (command != null) { command.PreExecute(Client, parameters); } else { Client.Send(new ConsoleMessage("Commande invalide", ConsoleColorEnum.RED)); } } else { Client.Send(new ConsoleMessage("Votre compte n'est pas autoriser a executer ce type de commande", ConsoleColorEnum.RED)); } }
/// <summary> /// Unloads all plugins. /// </summary> public static void UnloadAll() { if (IsLocked) { throw new NotSupportedException(); } IsLocked = true; foreach (var key in Plugins.Keys) { if (Plugins.TryGetValue(key, out var plugin) && plugin.LoadStatus == PluginContainer.Status.Loaded) { plugin.LoadStatus = PluginContainer.Status.Unloaded; try { plugin.Plugin.OnUnloadPlugin(); (plugin as IDisposable)?.Dispose(); } catch (HaltPluginException) { } catch (Exception e) { plugin.SetFailState(e); } AdminCommandManager.UnloadPlugin(plugin.Plugin); ConVarManager.UnloadPlugin(plugin.Plugin); plugin.Plugin = null; } } Plugins.Clear(); IsLocked = false; AdminManager.ReloadAdmins(); }
/// <summary> /// Unloads a plugin. /// </summary> /// <param name="name">The name of the plugin.</param> public static void Unload(string name) { if (IsLocked) { throw new NotSupportedException(); } var key = NameToKey(name); if (Plugins.TryGetValue(key, out var plugin)) { plugin.LoadStatus = PluginContainer.Status.Unloaded; try { IsLocked = true; plugin.Plugin.OnUnloadPlugin(); (plugin as IDisposable)?.Dispose(); IsLocked = false; } catch (HaltPluginException) { } catch (Exception e) { plugin.SetFailState(e); } Language.UnloadPlugin(plugin.Plugin); AdminCommandManager.UnloadPlugin(plugin.Plugin); ConVarManager.UnloadPlugin(plugin.Plugin); plugin.Plugin = null; AdminManager.ReloadAdmins(); Plugins.Remove(key); } }
/// <summary> /// Removes an <see cref="AdminCommand"/>. /// </summary> /// <param name="cmd">The name of the admin command.</param> protected void UnregAdminCommand(string cmd) { AdminCommandManager.RemoveCommand(this, cmd); }
/// <summary> /// Creates a new <see cref="AdminCommand"/> or returns the existing one if one with the same name already exists. /// </summary> /// <param name="cmd">The name of the admin command.</param> /// <param name="accessFlags">The <see cref="AdminFlags"/> value required to execute the admin command.</param> /// <param name="description">An optional description for the admin command.</param> /// <returns>The <see cref="AdminCommand"/> object representing the admin command.</returns> protected AdminCommand RegAdminCmd(string cmd, AdminFlags accessFlags, string description = "") { return(AdminCommandManager.CreateCommand(this, cmd, accessFlags, description)); }
/// <summary> /// Find an existing admin command with the specified name. /// </summary> /// <param name="command">The name of the admin command to locate.</param> /// <returns>The <see cref="AdminCommand"/> object representing the admin command if found; otherwise <c>null</c>.</returns> protected AdminCommand FindAdminCommand(string command) { return(AdminCommandManager.FindCommand(this, command)); }