public static void LoadPlugins(Configuration config) { Config = config; if (!Directory.Exists(config.PluginDirectory)) { Directory.CreateDirectory(config.PluginDirectory); } if (!Directory.Exists(config.PluginDataDirectory)) { Directory.CreateDirectory(config.PluginDataDirectory); } foreach (string p in config.Plugins) { try { LoadPlugin(p); } catch (Exception ex) { Console.WriteLine("[PluginManager] Problem loading plugin: {0}", p); Console.WriteLine("[PluginManager] Dumped error in PluginManagerException.txt"); Console.WriteLine("[PluginManager] Make sure you marked it as safe! Instructions at http://tmod.biz/forum/"); using (StreamWriter writer = new StreamWriter("PluginManagerException.txt", true)) { writer.WriteLine(DateTime.Now); writer.WriteLine(ex); writer.WriteLine(""); } } } }
public static void LoadConfig(bool ConfigMode = false) { #if !DEBUG if (File.Exists(ConfigFile)) { XmlSerializer xml = new XmlSerializer(typeof(Configuration)); FileStream fs = File.OpenRead(ConfigFile); Config = (Configuration)xml.Deserialize(fs); fs.Close(); } else { #endif Config = new Configuration(); #if !DEBUG } #endif if (!File.Exists("Groups.xml")) { Groups = new Groups(); Config.Ops.Add("127.0.0.1"); Groups.Default.GroupPermissions.AddRange(new string[] { "/playing", "/about", "/list", "/who", "/p", "/party", "/me", "/help", "/motd", "/login", "/id", "/identify", "/register", "/spawn", "/getpos", "/mypos", }); Groups.Member.GroupPermissions.AddRange(new string[] { "/opme", "/changepw", "/changepassword", "/changelogin", }); Groups.Mods.GroupPermissions.AddRange(new string[] { "/mute", "/unmute", "/slience", "/ban", "/unban", "/pandon", "/kick", "/d", "/drop", "/i", "/item", "/give", "/npc", "/summon", "/mob", "/say", "/broadcast", "/b", "/moderate", "/allowbuild", "/allowbreak", "/allowbomb", "/allowwater", "/allowlava", "/allowspike", "/butcher", "/butcherall", "/kill", "/heal", "/hearts", "/giveheart", "/peace", "/peaceful", "/pvp", "/allowregister", "/day", "/night", "/dusk", "/noon", "/midnight", "/whois", "/ip", "/rollback", "/rban", "/check", }); Groups.Ops.GroupPermissions.Add("*"); Group Donator = new Group(); Donator.GroupName = "Donator"; Groups.CustomGroups.Add(Donator); } else { Console.WriteLine("Deserializing Groups.xml..."); try { XmlSerializer xml = new XmlSerializer(typeof(Groups)); FileStream fs = File.OpenRead("Groups.xml"); Groups = (Groups)xml.Deserialize(fs); fs.Close(); } catch (Exception ex) { Console.WriteLine("[Groups] Problem deserializing Groups.xml, check it's valid."); Console.WriteLine(ex.Message); } } if (!ConfigMode) { MainMod.motd = Config.MOTD; NetplayMod.ServerListenIP = IPAddress.Parse(Config.BindAddress); NetplayMod.ServerPort = Config.BindPort; NetplayMod.password = Config.ServerPassword; NPCMod.DefaultSpawnRate = NPCMod.SpawnRate = Config.SpawnRate; NPCMod.DefaultMaxSpawns = NPCMod.MaxSpawns = Config.MaximumSpawns; } if(!Groups.Default.GroupPermissions.Contains("/about")) { Console.WriteLine("/about HAS to be enabled, sorry."); Groups.Default.GroupPermissions.Add("/about"); } if(!ConfigMode) LoadOldOps(); SaveConfig(); if (ConfigLoaded != null) { ConfigLoaded.Invoke(null, new ConfigLoadedEventArgs(ConfigFile)); } }