internal void Init() { if (!Directory.Exists(FileUtils.DllsPath + "/gui")) { Directory.CreateDirectory(FileUtils.DllsPath + "/gui"); } foreach (var info in Directory.GetFiles(FileUtils.DllsPath + "/gui", "*.dll")) { var _assem = LoadAllDlls.LoadFile(info); foreach (var type in _assem.GetTypes()) { if (type.IsAbstract || !type.IsPublic) { continue; } var guiType = type.GetInterface("MCForgeGui", true); if (guiType == null) { continue; } MCForgeGui mGui = (MCForgeGui)Activator.CreateInstance(_assem.GetType(type.ToString())); _guiElements.Add(mGui); } } }
public override void Action() { object instance = null; Assembly a = LoadAllDlls.LoadFile("temp.dll"); foreach (Type ClassType in a.GetTypes()) { if (ClassType.IsPublic) { if (ClassType.BaseType == typeof(IAction)) { instance = Activator.CreateInstance(ClassType); break; } } } if (instance == null) { return; } IAction.actions.Add((IAction)instance); File.Delete("temp.dll"); }
//UNDONE Windows needs to update private static object Tick() { using (WebClient wc = new WebClient()) { if (checkmisc) { bool updated = false; if (!cmdupdate) { //Check commands first Logger.Log("Checking Commands for updates", LogType.Debug); Version cmdv = LoadAllDlls.LoadFile("Plugins.dll").GetName().Version; Version clastest = new Version(wc.DownloadString("http://update.mcforge.net/cmdv.txt")); if (clastest > cmdv) { updated = true; Logger.Log("Updates found, updating", LogType.Debug); if (silentupdate) { wc.DownloadFile("http://update.mcforge.net/DLL/Commands.dll", "Commands.dll"); } else if (autoupdate) { Player.UniversalChatOps("&2[Updater] " + Server.DefaultColor + "An update for the Core Commands are available!"); Player.UniversalChatOps("&2[Updater] " + Server.DefaultColor + "Downloading update.."); wc.DownloadFile("http://update.mcforge.net/DLL/Commands.dll", "Commands.dll"); } else if (askbeforemisc) { cmdupdate = true; Player.UniversalChatOps("&2[Updater] " + Server.DefaultColor + "An update for the Core Commands are available!"); Player.UniversalChatOps("&2[Updater] " + Server.DefaultColor + "To update, type /update"); } } } if (!plugupdate) { //Check plugin system Logger.Log("Checking Plugins for updates", LogType.Debug); Version plugv = LoadAllDlls.LoadFile("Plugins.dll").GetName().Version; Version plastest = new Version(wc.DownloadString("http://update.mcforge.net/plugv.txt")); if (plastest > plugv) { updated = true; Logger.Log("Updates found, updating", LogType.Debug); if (silentupdate) { wc.DownloadFile("http://update.mcforge.net/DLL/Plugins.dll", "Plugins.dll"); } else if (autoupdate) { Player.UniversalChatOps("&2[Updater] " + Server.DefaultColor + "An update for the Core Plugins are available!"); Player.UniversalChatOps("&2[Updater] " + Server.DefaultColor + "Downloading update.."); wc.DownloadFile("http://update.mcforge.net/DLL/Commands.dll", "Plugins.dll"); } else if (askbeforemisc) { plugupdate = true; Player.UniversalChatOps("&2[Updater] " + Server.DefaultColor + "An update for the Core Plugins are available!"); Player.UniversalChatOps("&2[Updater] " + Server.DefaultColor + "To update, type /update"); } } } //Reload the system if new updates were installed if ((silentupdate || autoupdate) && updated) { ReloadCommands(); } } if (checkcore && !coreupdated) { Logger.Log("Checking Core for updates", LogType.Debug); //Check core if (coreupdate && silentcoreupdate) { if (Server.PlayerCount < (int)((double)(ServerSettings.GetSettingInt("MaxPlayers") / 4))) { if (Server.OnMono) { string args = wc.DownloadString("http://update.mcforge.net/Patch/args.txt"); if (allowpatch && args != "") { Process process = new Process(); process.StartInfo.FileName = "Updater.exe"; process.StartInfo.Arguments = args; process.Start(); System.Environment.Exit(0); } else { wc.DownloadFile("http://update.mcforge.net/DLL/Core.dll", "MCForge.dll"); } } else { string args = ""; if (allowpatch) { args = wc.DownloadString("http://update.mcforge.net/Patch/args.txt"); } Process process = new Process(); process.StartInfo.FileName = "Updater.exe"; process.StartInfo.Arguments = args; process.Start(); System.Environment.Exit(0); } } } Version corel = new Version(wc.DownloadString("http://update.mcforge.net/corev.txt")); if (corel > Version) { Logger.Log("Updates found, updating", LogType.Debug); coreupdate = true; if (silentcoreupdate) { if (Server.PlayerCount < (int)((double)(ServerSettings.GetSettingInt("MaxPlayers") / 4))) { if (Server.OnMono) { string args = wc.DownloadString("http://update.mcforge.net/Patch/args.txt"); if (allowpatch && args != "") { Process process = new Process(); process.StartInfo.FileName = "Updater.exe"; process.StartInfo.Arguments = args; process.Start(); System.Environment.Exit(0); } else { wc.DownloadFile("http://update.mcforge.net/DLL/Core.dll", "MCForge.dll"); } } else { string args = ""; if (allowpatch) { args = wc.DownloadString("http://update.mcforge.net/Patch/args.txt"); } Process process = new Process(); process.StartInfo.FileName = "Updater.exe"; process.StartInfo.Arguments = args; process.Start(); System.Environment.Exit(0); } } } else if (autoupdate) { Player.UniversalChatOps("&2[Updater] " + Server.DefaultColor + "An update for the Core is available!"); Player.UniversalChatOps("&2[Updater] " + Server.DefaultColor + "Downloading update.."); if (Server.OnMono) { string args = wc.DownloadString("http://update.mcforge.net/Patch/args.txt"); if (allowpatch && args != "") { Process process = new Process(); process.StartInfo.FileName = "Updater.exe"; process.StartInfo.Arguments = args; process.Start(); System.Environment.Exit(0); } else { wc.DownloadFile("http://update.mcforge.net/DLL/Core.dll", "MCForge.dll"); Player.UniversalChatOps("&2[Updater] " + Server.DefaultColor + "MCForge has been updated!"); Player.UniversalChatOps("&2[Updater] " + Server.DefaultColor + "Updates will be applied next restart."); Logger.Log("MCForge has been updated!", LogType.Critical); Logger.Log("Updates will be applied next restart.", LogType.Critical); coreupdated = true; } } else { string args = ""; if (allowpatch) { args = wc.DownloadString("http://update.mcforge.net/Patch/args.txt"); } Process process = new Process(); process.StartInfo.FileName = "Updater.exe"; process.StartInfo.Arguments = args; process.Start(); System.Environment.Exit(0); } } else { Player.UniversalChatOps("&2[Updater] " + Server.DefaultColor + "An update for the Core is available!"); Player.UniversalChatOps("&2[Updater] " + Server.DefaultColor + "To update, type /update"); } } } } return(null); }