public static bool Load(Plugin p, bool auto) { try { string ver = p.MCGalaxy_Version; if (!String.IsNullOrEmpty(ver) && new Version(ver) > new Version(Server.Version)) { Logger.Log(LogType.Warning, "Plugin ({0}) requires a more recent version of {1}!", p.name, Server.SoftwareName); return(false); } all.Add(p); if (p.LoadAtStartup || !auto) { p.Load(auto); Logger.Log(LogType.SystemActivity, "Plugin {0} loaded...build: {1}", p.name, p.build); } else { Logger.Log(LogType.SystemActivity, "Plugin {0} was not loaded, you can load it with /pload", p.name); } if (!String.IsNullOrEmpty(p.welcome)) { Logger.Log(LogType.SystemActivity, p.welcome); } return(true); } catch (Exception ex) { Logger.LogError("Error loading plugin " + p.name, ex); if (!String.IsNullOrEmpty(p.creator)) { Logger.Log(LogType.Warning, "You can go bug {0} about it.", p.creator); } return(false); } }
public static void LoadAllSettings() { // Unload custom plugins List <Plugin> plugins = new List <Plugin>(Plugin.all); foreach (Plugin p in plugins) { if (Plugin.core.Contains(p)) { continue; } Plugin.Unload(p, false); } ZSGame.Instance.infectMessages = ZSConfig.LoadInfectMessages(); Colors.Load(); Alias.Load(); BlockDefinition.LoadGlobal(); ImagePalette.Load(); SrvProperties.Load(); AuthService.ReloadDefault(); Group.LoadAll(); CommandPerms.Load(); Command.InitAll(); Block.SetBlocks(); AwardsList.Load(); PlayerAwards.Load(); Economy.Load(); WarpList.Global.Filename = "extra/warps.save"; WarpList.Global.Load(); CommandExtraPerms.Load(); ProfanityFilter.Init(); Team.LoadList(); ChatTokens.LoadCustom(); SrvProperties.FixupOldPerms(); CpeExtension.LoadDisabledList(); TextFile announcementsFile = TextFile.Files["Announcements"]; announcementsFile.EnsureExists(); announcements = announcementsFile.GetText(); // Reload custom plugins foreach (Plugin p in plugins) { if (Plugin.core.Contains(p)) { continue; } Plugin.Load(p, false); } OnConfigUpdatedEvent.Call(); }
static void LoadCorePlugin(Plugin plugin) { plugin.Load(true); Plugin.all.Add(plugin); Plugin.core.Add(plugin); }
public static void Start() { serverConfig = ConfigElement.GetAll(typeof(ServerConfig)); zombieConfig = ConfigElement.GetAll(typeof(ZSConfig)); levelConfig = ConfigElement.GetAll(typeof(LevelConfig)); zoneConfig = ConfigElement.GetAll(typeof(ZoneConfig)); #pragma warning disable 0618 Player.players = PlayerInfo.Online.list; Server.levels = LevelInfo.Loaded.list; #pragma warning restore 0618 StartTime = DateTime.UtcNow; shuttingDown = false; Logger.Log(LogType.SystemActivity, "Starting Server"); ServicePointManager.Expect100Continue = false; CheckFile("MySql.Data.dll"); CheckFile("System.Data.SQLite.dll"); CheckFile("sqlite3_x32.dll"); CheckFile("sqlite3_x64.dll"); CheckFile("Newtonsoft.Json.dll"); CheckFile("LibNoise.dll"); EnsureFilesExist(); MoveSqliteDll(); MoveOutdatedFiles(); lava = new LavaSurvival(); zombie = new ZSGame(); Countdown = new CountdownGame(); LoadAllSettings(); SrvProperties.GenerateSalt(); InitDatabase(); Economy.LoadDatabase(); Server.zombie.CheckTableExists(); Background.QueueOnce(UpgradeTasks.CombineEnvFiles); Background.QueueOnce(LoadMainLevel); Plugin.Load(); Background.QueueOnce(UpgradeTasks.UpgradeOldBlacklist); Background.QueueOnce(LoadAutoloadMaps); Background.QueueOnce(UpgradeTasks.MovePreviousLevelFiles); Background.QueueOnce(UpgradeTasks.UpgradeOldTempranks); Background.QueueOnce(UpgradeTasks.UpgradeDBTimeSpent); Background.QueueOnce(LoadPlayerLists); Background.QueueOnce(UpgradeTasks.UpgradeOldLockdown); Background.QueueOnce(UpgradeTasks.UpgradeBots); Background.QueueOnce(SetupSocket); Background.QueueOnce(InitTimers); Background.QueueOnce(InitRest); Background.QueueOnce(InitHeartbeat); Devs.Clear(); Mods.Clear(); Background.QueueOnce(InitTasks.UpdateStaffList); ServerTasks.QueueTasks(); Background.QueueRepeat(ThreadSafeCache.DBCache.CleanupTask, null, TimeSpan.FromMinutes(5)); }
public void Start() { serverConfig = ConfigElement.GetAll(typeof(Server), typeof(ZombieGameProps)); levelConfig = ConfigElement.GetAll(typeof(Level)); #pragma warning disable 0618 Player.players = PlayerInfo.Online.list; PlayerInfo.players = PlayerInfo.Online.list; Server.levels = LevelInfo.Loaded.list; PlayerBot.playerbots = PlayerBot.Bots.list; #pragma warning restore 0618 StartTime = DateTime.UtcNow; StartTimeLocal = StartTime.ToLocalTime(); shuttingDown = false; Log("Starting Server"); try { if (File.Exists("Restarter.exe")) { File.Delete("Restarter.exe"); } } catch { } try { if (File.Exists("Restarter.pdb")) { File.Delete("Restarter.pdb"); } } catch { } CheckFile("MySql.Data.dll"); CheckFile("System.Data.SQLite.dll"); CheckFile("sqlite3.dll"); CheckFile("Newtonsoft.Json.dll"); CheckFile("LibNoise.dll"); EnsureFilesExist(); MoveOutdatedFiles(); lava = new LavaSurvival(); zombie = new ZombieGame(); Countdown = new CountdownGame(); LoadAllSettings(); InitDatabase(); Economy.LoadDatabase(); Server.zombie.CheckTableExists(); Level[] loaded = LevelInfo.Loaded.Items; foreach (Level l in loaded) { l.Unload(); } Background.QueueOnce(UpgradeTasks.CombineEnvFiles); Background.QueueOnce(LoadMainLevel); Plugin.Load(); Background.QueueOnce(UpgradeTasks.UpgradeOldBlacklist); Background.QueueOnce(LoadPlayerLists); Background.QueueOnce(LoadAutoloadCommands); Background.QueueOnce(UpgradeTasks.MovePreviousLevelFiles); Background.QueueOnce(UpgradeTasks.UpgradeOldLockdown); Background.QueueOnce(SetupSocket); Background.QueueOnce(InitTimers); Background.QueueOnce(InitRest); Background.QueueOnce(InitHeartbeat); Devs.Clear(); Mods.Clear(); Background.QueueOnce(InitTasks.UpdateStaffList); MainScheduler.QueueRepeat(ServerTasks.TemprankExpiry, null, TimeSpan.FromMinutes(1)); Background.QueueRepeat(ServerTasks.AutoSave, 1, TimeSpan.FromSeconds(Server.backupInterval)); Background.QueueRepeat(ServerTasks.BlockUpdates, null, TimeSpan.FromSeconds(Server.blockInterval)); Background.QueueRepeat(ThreadSafeCache.DBCache.CleanupTask, null, TimeSpan.FromMinutes(5)); }
public void Start() { serverConfig = ConfigElement.GetAll(typeof(Server), typeof(ZombieGame)); PlayerInfo.players = PlayerInfo.Online.list; Player.players = PlayerInfo.Online.list; Server.levels = LevelInfo.Loaded.list; PlayerBot.playerbots = PlayerBot.Bots.list; StartTime = DateTime.UtcNow; StartTimeLocal = StartTime.ToLocalTime(); shuttingDown = false; Log("Starting Server"); try { if (File.Exists("Restarter.exe")) { File.Delete("Restarter.exe"); } } catch { } try { if (File.Exists("Restarter.pdb")) { File.Delete("Restarter.pdb"); } } catch { } CheckFile("MySql.Data.dll"); CheckFile("System.Data.SQLite.dll"); CheckFile("sqlite3.dll"); CheckFile("Newtonsoft.Json.dll"); CheckFile("LibNoise.dll"); EnsureFilesExist(); MoveOutdatedFiles(); Chat.LoadCustomTokens(); if (File.Exists("text/emotelist.txt")) { foreach (string s in File.ReadAllLines("text/emotelist.txt")) { Player.emoteList.Add(s); } } else { File.Create("text/emotelist.txt").Dispose(); } lava = new LavaSurvival(); zombie = new ZombieGame(); Countdown = new CountdownGame(); LoadAllSettings(); InitDatabase(); Economy.LoadDatabase(); Server.zombie.CheckTableExists(); Level[] loaded = LevelInfo.Loaded.Items; foreach (Level l in loaded) { l.Unload(); } ml.Queue(LoadMainLevel); Plugin.Load(); ml.Queue(LoadPlayerLists); ml.Queue(LoadAutoloadCommands); ml.Queue(LoadGCAccepted); ml.Queue(InitTimers); ml.Queue(InitRest); ml.Queue(InitHeartbeat); UpdateStaffList(); }
/// <summary> Load a plugin </summary> /// <param name="name">The name of the plugin.</param> /// <param name="startup">Is this startup?</param> public static void Load(string name, bool startup) { string creator = ""; string path = "plugins/" + name + ".dll"; try { Plugin instance = null; byte[] data = File.ReadAllBytes(path); Assembly lib = Assembly.Load(data); try { foreach (Type t in lib.GetTypes()) { if (!t.IsSubclassOf(typeof(Plugin))) { continue; } instance = (Plugin)Activator.CreateInstance(t); break; } } catch { } if (instance == null) { Server.s.Log("The plugin " + name + " couldn't be loaded!"); return; } creator = instance.creator; string ver = instance.MCGalaxy_Version; if (!String.IsNullOrEmpty(ver) && new Version(ver) > Server.Version) { Server.s.Log("This plugin (" + instance.name + ") isn't compatible with this version of MCGalaxy!"); Thread.Sleep(1000); if (!Server.unsafe_plugin) { return; } Server.s.Log("Will attempt to load!"); } Plugin.all.Add(instance); if (instance.LoadAtStartup) { instance.Load(startup); Server.s.Log("Plugin: " + instance.name + " loaded...build: " + instance.build); } else { Server.s.Log("Plugin: " + instance.name + " was not loaded, you can load it with /pload"); } Server.s.Log(instance.welcome); } catch (Exception e) { Server.ErrorLog(e); Server.s.Log("The plugin " + name + " failed to load!"); if (creator != "") { Server.s.Log("You can go bug " + creator + " about it."); } Thread.Sleep(1000); } }
/// <summary> Load a plugin </summary> /// <param name="name">The name of the plugin.</param> /// <param name="startup">Is this startup?</param> public static void Load(string name, bool startup) { string creator = ""; string path = "plugins/" + name + ".dll"; try { Plugin instance = null; byte[] data = File.ReadAllBytes(path); Assembly lib = Assembly.Load(data); try { foreach (Type t in lib.GetTypes()) { if (!t.IsSubclassOf(typeof(Plugin))) { continue; } instance = (Plugin)Activator.CreateInstance(t); break; } } catch { } if (instance == null) { Logger.Log(LogType.Warning, "The plugin {0} couldn't be loaded!", name); return; } creator = instance.creator; string ver = instance.MCGalaxy_Version; if (!String.IsNullOrEmpty(ver) && new Version(ver) > Server.Version) { Logger.Log(LogType.Warning, "This plugin ({0}) isn't compatible with this version of {1}!", instance.name, Server.SoftwareName); Thread.Sleep(1000); if (!ServerConfig.unsafe_plugin) { return; } Logger.Log(LogType.Warning, "Will attempt to load plugin anyways!"); } Plugin.all.Add(instance); if (instance.LoadAtStartup) { instance.Load(startup); Logger.Log(LogType.SystemActivity, "Plugin: {0} loaded...build: {1}", instance.name, instance.build); } else { Logger.Log(LogType.SystemActivity, "Plugin: {0} was not loaded, you can load it with /pload", instance.name); } Logger.Log(LogType.SystemActivity, instance.welcome); } catch (Exception e) { Logger.LogError(e); Logger.Log(LogType.Warning, "The plugin {0} failed to load!", name); if (creator.Length > 0) { Logger.Log(LogType.Warning, "You can go bug {0} about it.", creator); } Thread.Sleep(1000); } }