Esempio n. 1
0
        private static void Main(string[] args)
        {
            reader = new ConsoleReader();
            reader.Title = "Gateway server, type help for commands";
            reader.Initialize += new EventHandler(reader_Initialize);
            reader.Register(new ConsoleCommandHandler(Version));
            reader.Register(new ConsoleCommandHandler(CrcValidationCheck));
            reader.Register(new ConsoleCommandHandler(CheckHost));
            reader.Register(new ConsoleCommandHandler(Shutdown));
            reader.Clear(null);

            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            //SagaConfigurationManager.read();
            string file = System.Reflection.Assembly.GetExecutingAssembly().Location;
            string fname = Path.GetFileNameWithoutExtension(file);

            //TRACELOG
            Trace.AutoFlush = true;
            Trace.IndentSize = 4;
            if (System.Diagnostics.Trace.Listeners.Count <= 1 && (System.Diagnostics.Trace.Listeners["Default"] == null ||
                System.Diagnostics.Trace.Listeners["Default"].GetType() == typeof(System.Diagnostics.DefaultTraceListener)))
            {
                DelimitedListTraceListener del = new System.Diagnostics.DelimitedListTraceListener((fname + ".log.csv"), "text");
                del.Delimiter = ",";
                System.Diagnostics.Trace.Listeners.Add(del);
            }

            Trace.WriteLine("#############################################################################");
            Trace.WriteLine(string.Format("Saga Gateway Server starting on: {0}", DateTime.Now));
            Trace.WriteLine(string.Format("OS Information: {0}", Environment.OSVersion));
            Trace.WriteLine(string.Format("Number of Processors: {0}", Environment.ProcessorCount));
            Trace.WriteLine(string.Format("CLR Version: {0}", Environment.Version));
            Trace.WriteLine(string.Format("Working set: {0}", Environment.WorkingSet));
            Trace.WriteLine(string.Format("OS Bit Version: {0} Bit", IntPtr.Size * 8));
            Trace.WriteLine("#############################################################################");

            System.Configuration.Configuration b =
                ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

            if (CheckConfigExists() == false)
            {
                Console.WriteLine("First time run-configuration");
                char key;

            ConfigureGatewayNetwork:
                Console.WriteLine("Do you wan to configure the gateway-network settings? Y/N");
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("What ip should the gateway server listen to?");
                    while (!IPAddress.TryParse(Console.ReadLine(), out gatewayip))
                    {
                        Console.WriteLine("Incorrect value please use an ipv4 adress, recommended 0.0.0.0");
                    }

                    Console.WriteLine("What port should the gateway server listen to?");
                    while (!int.TryParse(Console.ReadLine(), out gatewayport))
                    {
                        Console.WriteLine("Incorrect value please use an number between 1024–49151, recommended 64000");
                    }
                }
                else if (key != 'n') goto ConfigureGatewayNetwork;

            ConfigureAuthenticationNetwork:
                Console.WriteLine("Do you wan to configure the authentication-network settings? Y/N");
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("What is the ip of the authentication server");
                    while (!IPAddress.TryParse(Console.ReadLine(), out authenticationip))
                    {
                        Console.WriteLine("Incorrect value please use an ipv4 adress, recommended 0.0.0.0");
                    }

                    Console.WriteLine("On what port is the authentication server listening");
                    while (!int.TryParse(Console.ReadLine(), out authenticationport))
                    {
                        Console.WriteLine("Incorrect value please use an number between 1024–49151, recommended 64000");
                    }
                }
                else if (key != 'n') goto ConfigureAuthenticationNetwork;

            ConfigureGUID:
                Console.WriteLine("Do you wan to configure the gateway-guid settings? Y/N");
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("What is the crc key");
                    byte[] ncrckey;
                    while (!Conversions.TryParse(Console.ReadLine(), out ncrckey) || crckey.Length != 20)
                    {
                        Console.WriteLine("Crc key key must be 20 hex digit string, recommended: A928CDC9DBE8751B3BC99EB65AE07E0C849CE739");
                    }

                    Console.WriteLine("What is the guid key");
                    byte[] nguidkey;
                    while (!Conversions.TryParse(Console.ReadLine(), out nguidkey) || guidkey.Length != 20)
                    {
                        Console.WriteLine("Guid key key must be 20 hex digit string, recommended: ED90AA25AE906FB36308C8523A4737A7E7B1FC6F");
                    }

                    crckey = Conversions.ByteToHexString(ncrckey);
                    guidkey = Conversions.ByteToHexString(nguidkey);
                }
                else if (key != 'n') goto ConfigureGUID;

                NetworkSettings networkSettings = new NetworkSettings();
                NetworkFileCollection collection = networkSettings.Connections;
                collection["public"] = new NetworkElement("public", gatewayip.ToString(), gatewayport);
                collection["internal"] = new NetworkElement("internal", authenticationip.ToString(), authenticationport);
                networkSettings.Crckey = crckey;
                networkSettings.Guidkey = guidkey;
                b.Sections.Remove("Saga.NetworkSettings");
                b.Sections.Add("Saga.NetworkSettings", networkSettings);
                b.Save();
                ConfigurationManager.RefreshSection("Saga.NetworkSettings");

                Console.WriteLine("Everything configured");
                LoginClient client;
                for (int i = 0; i < 3; i++)
                {
                    if (NetworkManager.TryGetLoginClient(out client))
                    {
                        Console.WriteLine("Test connection created");
                        client.Close();
                        break;
                    }
                    else
                    {
                        Thread.Sleep(3000);
                        Console.WriteLine("Test connection failed retrying in 3 secconds");
                    }
                }
            }
            else
            {
                LoginClient client;
                Console.WriteLine("Configuration file exists");
                Console.WriteLine("Trying to connect to authentication-server...");
                if (NetworkManager.TryGetLoginClient(out client))
                {
                    client.ExchangeIpAdress(IPAddress.Loopback);
                    Console.WriteLine("Connection to authentication-server is create");
                }
                else
                {
                    switch (NetworkManager.LastError)
                    {
                        case NetworkManager.NetworkError.InvalidHost:
                        Console.WriteLine("Host is invalid");
                        break;

                    case NetworkManager.NetworkError.Refused:
                        Console.WriteLine("Target machine activly refused the connection");
                        break;

                    case NetworkManager.NetworkError.Unknown:
                        Console.WriteLine("Unknown exception occured");
                        break;

                    case NetworkManager.NetworkError.Unreachable:
                        Console.WriteLine("Target machin is unreachable");
                        break;
                    }
                }
            }

            reader.Start();
        }
Esempio n. 2
0
        private static void FirstRunConfiguration()
        {
            IPAddress gatewayip = IPAddress.Loopback;
            int gatewayport = 64001;
            IPAddress mapip = IPAddress.Loopback;
            int mapport = 64002;
            string databaseusername = "******";
            string databasepassword = "******";
            uint dbport = 3306;
            string databasename = "saga_auth";
            string dbhost = "localhost";
            string provider = "Saga.Authentication.Data.Mysql.dll, Saga.Authentication.Data.Mysql.MysqlProvider";
            ConsoleReader reader = new ConsoleReader();
            reader.Clear(null);

            System.Configuration.Configuration b = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            if (CheckConfigExists() == false)
            {
                Console.WriteLine("First time run-configuration");
                char key;

                provider = FindPlugin(typeof(IDatabase), "Saga.Authentication.Data.Mysql.dll, Saga.Authentication.Data.Mysql.MysqlProvider");

            ConfigureGatewayNetwork:
                Console.WriteLine("Do you wan to configure the authentication-gateway network settings? Y/N");
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("What ip should the authentication-gateway server listen to?");
                    while (!IPAddress.TryParse(Console.ReadLine(), out gatewayip))
                    {
                        Console.WriteLine("Incorrect value please use an ipv4 adress, recommended 0.0.0.0");
                    }

                    Console.WriteLine("What port should the authentication-gateway server listen to?");
                    while (!int.TryParse(Console.ReadLine(), out gatewayport))
                    {
                        Console.WriteLine("Incorrect value please use an number between 1024�49151, recommended 64001");
                    }
                }
                else if (key != 'n') goto ConfigureGatewayNetwork;

            ConfigureWorldNetwork:
                Console.WriteLine("Do you wan to configure the authentication-map network settings? Y/N");
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("What ip should the authentication-map server listen to?");
                    while (!IPAddress.TryParse(Console.ReadLine(), out mapip))
                    {
                        Console.WriteLine("Incorrect value please use an ipv4 adress, recommended 0.0.0.0");
                    }

                    Console.WriteLine("On what port is the authentication server listening");
                    while (!int.TryParse(Console.ReadLine(), out mapport))
                    {
                        Console.WriteLine("Incorrect value please use an number between 1024�49151, recommended 64000");
                    }
                }
                else if (key != 'n') goto ConfigureWorldNetwork;

            DatabaseName:
                Console.WriteLine("Do you wan to configure the database settings? Y/N");
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("What is the database name?");
                    databasename = Console.ReadLine();

                    Console.WriteLine("What is the database username?");
                    databaseusername = Console.ReadLine();

                    Console.WriteLine("What is the database password?");
                    databasepassword = Console.ReadLine();

                    Console.WriteLine("What is the database port?");
                    while (!uint.TryParse(Console.ReadLine(), out dbport))
                    {
                        Console.WriteLine("Incorrect value please use an number between 1024�49151, recommended 3306");
                    }

                    Console.WriteLine("What is the database host?");
                    dbhost = Console.ReadLine();
                }
                else if (key != 'n') goto DatabaseName;

                //Adjust network settings
                NetworkSettings networkSettings = b.Sections["Saga.NetworkSettings"] as NetworkSettings;
                if (networkSettings == null) networkSettings = new NetworkSettings();

                NetworkFileCollection collection = networkSettings.Connections;
                collection["public"] = new NetworkElement("public", gatewayip.ToString(), gatewayport);
                collection["internal"] = new NetworkElement("internal", mapip.ToString(), mapport);
                b.Sections.Remove("Saga.NetworkSettings");
                b.Sections.Add("Saga.NetworkSettings", networkSettings);

                //Adjust database settings
                DatabaseSettings databaseSettings = b.Sections["Saga.Manager.Database"] as DatabaseSettings;
                if (databaseSettings == null) databaseSettings = new DatabaseSettings();
                databaseSettings.Database = databasename;
                databaseSettings.Username = databaseusername;
                databaseSettings.Password = databasepassword;
                databaseSettings.Port = dbport;
                databaseSettings.Host = dbhost;
                databaseSettings.DbType = provider;
                b.Sections.Remove("Saga.Manager.Database");
                b.Sections.Add("Saga.Manager.Database", databaseSettings);
                b.Save();
                ConfigurationManager.RefreshSection("Saga.NetworkSettings");
                ConfigurationManager.RefreshSection("Saga.Manager.Database");
                Console.WriteLine("Everything configured");
            }
        }
Esempio n. 3
0
        private static void FirstRunConfiguration()
        {
            IPAddress gatewayip = IPAddress.Loopback;
            int gatewayport = 64003;
            IPAddress mapip = IPAddress.Loopback;
            byte worldid = 0;
            int mapport = 64002;
            int playerlimit = 60;
            string databaseusername = "******";
            string databasepassword = "******";
            uint dbport = 3306;
            int cexprates = 1;
            int jexprates = 1;
            int wexprates = 1;
            int droprates = 1;
            string databasename = "saga_world";
            string dbhost = "localhost";
            string dbprovider = "Saga.Map.Data.Mysql.dll, Saga.Map.Data.Mysql.MysqlProvider";
            string proof = "c4ca4238a0b923820dcc509a6f75849b";
            string questplugin = "Saga.Map.Data.LuaQuest.dll, Saga.Map.Data.LuaQuest.LuaQuestProvider";
            string scenarioquestplugin = "Saga.Map.Data.LuaQuest.dll, Saga.Map.Data.LuaQuest.ScenarioLuaQuest";
            string worldspawn = "Saga.Map.Plugins.dll, Saga.Map.Plugins.MultifileSpawnWorldObjects";
            string multiworldspawn = "Saga.Map.Plugins.dll, Saga.Map.Plugins.MultifileSpawnMultiWorldObjects";
            string eventprovider = "Saga.Map.Data.LuaQuest.dll, Saga.Map.Data.LuaQuest.EventInfo";
            ConsoleReader reader = new ConsoleReader();
            reader.Clear(null);

            System.Configuration.Configuration b = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            if (CheckConfigExists() == false)
            {
                Console.WriteLine("First time run-configuration");
                char key;

                #region Always Configure

                ConfigureRequired("What is the world id of this server?");
                while (!byte.TryParse(Console.ReadLine(), out worldid))
                {
                    Console.WriteLine("Incorrect value please use an number between 0–255");
                }

                ConfigureRequired("What is the player limit of this server?");
                while (!int.TryParse(Console.ReadLine(), out playerlimit))
                {
                    Console.WriteLine("Incorrect value please use an valid number");
                }

                ConfigureRequired("What is the authentication proof of this server?");
                MD5 md5 = MD5.Create();
                byte[] block = Encoding.UTF8.GetBytes(Console.ReadLine());
                byte[] md5block = md5.ComputeHash(block);
                StringBuilder builder = new StringBuilder();
                foreach (byte c in md5block)
                    builder.AppendFormat("{0:X2}", c);
                proof = builder.ToString();

                ConfigureRequired("What are the cexp-rates?");
                while (!int.TryParse(Console.ReadLine(), out cexprates))
                {
                    Console.WriteLine("Incorrect value please use an between 1 and 20");
                }
                cexprates = Math.Min(20, Math.Max(cexprates, 1));

                ConfigureRequired("What are the jexp-rates?");
                while (!int.TryParse(Console.ReadLine(), out jexprates))
                {
                    Console.WriteLine("Incorrect value please use an between 1 and 20");
                }
                jexprates = Math.Min(20, Math.Max(jexprates, 1));

                ConfigureRequired("What are the wexp-rates?");
                while (!int.TryParse(Console.ReadLine(), out wexprates))
                {
                    Console.WriteLine("Incorrect value please use an between 1 and 20");
                }
                wexprates = Math.Min(20, Math.Max(wexprates, 1));

                ConfigureRequired("What are the item drop-rates?");
                while (!int.TryParse(Console.ReadLine(), out droprates))
                {
                    Console.WriteLine("Incorrect value please use an between 1 and 20");
                }
                droprates = Math.Min(20, Math.Max(droprates, 1));

                ConfigureRequired("Detect database plugin");
                dbprovider = FindPlugin(typeof(IDatabase), dbprovider);

                ConfigureRequired("Detect quest plugin");
                questplugin = FindPlugin(typeof(Saga.Quests.IQuest), questplugin);

                ConfigureRequired("Detect scenarion quest plugin");
                scenarioquestplugin = FindPlugin(typeof(Saga.Quests.ISceneraioQuest), scenarioquestplugin);

                ConfigureRequired("Detect npc & map spawn plugin");
                worldspawn = FindPlugin(typeof(Saga.Factory.SpawnWorldObjects), worldspawn);

                ConfigureRequired("Detect mob spawn plugin");
                multiworldspawn = FindPlugin(typeof(Saga.Factory.SpawnMultiWorldObjects), multiworldspawn);

                ConfigureRequired("Detect event plugin");
                eventprovider = FindPlugin(typeof(Saga.Factory.EventManager.BaseEventInfo), eventprovider);

                #endregion Always Configure

                #region Network Settings

            ConfigureGatewayNetwork:
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Do you wan to configure the gateway-map network settings? Y/N");
                Console.ResetColor();
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("What ip should the gateway-map server listen to?");
                    while (!IPAddress.TryParse(Console.ReadLine(), out gatewayip))
                    {
                        Console.WriteLine("Incorrect value please use an ipv4 adress, recommended 0.0.0.0");
                    }

                    Console.WriteLine("What port should the gateway-map server listen to?");
                    while (!int.TryParse(Console.ReadLine(), out gatewayport))
                    {
                        Console.WriteLine("Incorrect value please use an number between 1024–49151, recommended 64003");
                    }
                }
                else if (key != 'n') goto ConfigureGatewayNetwork;

            ConfigureWorldNetwork:
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Do you wan to configure the authentication-map network settings? Y/N");
                Console.ResetColor();
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("What ip should the authentication-map server listen to?");
                    while (!IPAddress.TryParse(Console.ReadLine(), out mapip))
                    {
                        Console.WriteLine("Incorrect value please use an ipv4 adress, recommended 0.0.0.0");
                    }

                    Console.WriteLine("On what port is the authentication server listening");
                    while (!int.TryParse(Console.ReadLine(), out mapport))
                    {
                        Console.WriteLine("Incorrect value please use an number between 1024–49151, recommended 64002");
                    }
                }
                else if (key != 'n') goto ConfigureWorldNetwork;

                #endregion Network Settings

                #region Database Settings

            DatabaseName:
                ConfigureOptional("Do you want to configure the database settings? Y/N");
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    ConfigureRequired("What is the database name?");
                    databasename = Console.ReadLine();

                    ConfigureRequired("What is the database username?");
                    databaseusername = Console.ReadLine();

                    ConfigureRequired("What is the database password?");
                    databasepassword = Console.ReadLine();

                    ConfigureRequired("What is the database port?");
                    while (!uint.TryParse(Console.ReadLine(), out dbport))
                    {
                        Console.WriteLine("Incorrect value please use an number between 1024–49151, recommended 3306");
                    }

                    ConfigureRequired("What is the database host?");
                    dbhost = Console.ReadLine();
                }
                else if (key != 'n') goto DatabaseName;

                #endregion Database Settings



                #region Plugin detection

            PluginDetection:
                ConfigureOptional("Do you want to dectect other plugins?");
                key = Console.ReadKey(true).KeyChar;
                if (key == 'y')
                {
                    Console.WriteLine("no plugins detected");
                }
                else if (key != 'n') goto PluginDetection;

                #endregion Plugin detection

                //CONFIGURE SERVER SETTINGS
                ServerVars serverVarsConfiguration = new ServerVars();
                serverVarsConfiguration.DataDirectory = "../Data/";
                b.Sections.Add("Saga.ServerVars", serverVarsConfiguration);

                //CONFIGURE NETWORK SETTINGS
                NetworkSettings networkSettings = new NetworkSettings();
                NetworkFileCollection collection = networkSettings.Connections;
                collection["public"] = new NetworkElement("public", gatewayip.ToString(), gatewayport);
                collection["internal"] = new NetworkElement("internal", mapip.ToString(), mapport);
                b.Sections.Remove("Saga.Manager.NetworkSettings");
                b.Sections.Add("Saga.Manager.NetworkSettings", networkSettings);
                networkSettings.WorldId = worldid;
                networkSettings.Proof = proof;
                networkSettings.PlayerLimit = playerlimit;

                //CONFIGURE CONSOLE SETTING
                ConsoleSettings consoleSettings = new ConsoleSettings();
                consoleSettings.CommandPrefix = "@";
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Broadcast"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Position"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.ChatMute"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.GmWarptomap"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.PlayerJump"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.PlayerCall"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Speed"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.GarbageCollector"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.ClearNpc"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.KickAll"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Kick"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Time"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.ShowMaintenance"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.ScheduleMaintenance"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.SetGmLevel"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Spawn"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Unspawn"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.GiveItem"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.QStart"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Kill"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Worldload"));
                consoleSettings.GmCommands.Add(new FactoryFileElement("Saga.Scripting.Console.Gmgo"));
                b.Sections.Add("Saga.Manager.ConsoleSettings", consoleSettings);

                //PORTALS
                PortalSettings portalSettings = new PortalSettings();
                portalSettings.FolderItems.Add(new FactoryFileElement("~/portal_data.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.Portals");
                b.Sections.Add("Saga.Factory.Portals", portalSettings);

                //CHARACTERCONFIGURATION
                CharacterConfigurationSettings characterconfigurationSettings = new CharacterConfigurationSettings();
                characterconfigurationSettings.FolderItems.Add(new FactoryFileElement("~/character-template.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.CharacterConfiguration");
                b.Sections.Add("Saga.Factory.CharacterConfiguration", characterconfigurationSettings);

                //ADDITION
                AdditionSettings additionSettings = new AdditionSettings();
                additionSettings.FolderItems.Add(new FactoryFileElement("~/Addition_t.xml", "text/xml"));
                additionSettings.Reference = "~/addition_reference.csv";
                b.Sections.Remove("Saga.Factory.Addition");
                b.Sections.Add("Saga.Factory.Addition", additionSettings);

                //SPELLS
                SpellSettings spellSettings = new SpellSettings();
                spellSettings.FolderItems.Add(new FactoryFileElement("~/spell_data.xml", "text/xml"));
                spellSettings.Reference = "~/skill_reference.csv";
                b.Sections.Remove("Saga.Factory.Spells");
                b.Sections.Add("Saga.Factory.Spells", spellSettings);

                //STATUSBYLEVEL
                StatusByLevelSettings statusbylevelSettings = new StatusByLevelSettings();
                statusbylevelSettings.FolderItems.Add(new FactoryFileElement("~/experience.csv", "text/csv"));
                statusbylevelSettings.Cexp = cexprates;
                statusbylevelSettings.Jexp = jexprates;
                statusbylevelSettings.Wexp = wexprates;
                statusbylevelSettings.Droprate = droprates;

                b.Sections.Remove("Saga.Factory.StatusByLevel");
                b.Sections.Add("Saga.Factory.StatusByLevel", statusbylevelSettings);

                //WARPSETTINGS
                WarpSettings warpSettings = new WarpSettings();
                warpSettings.FolderItems.Add(new FactoryFileElement("~/warp_data.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.Warps");
                b.Sections.Add("Saga.Factory.Warps", warpSettings);

                //ZONES
                ZoneSettings zoneSettings = new ZoneSettings();
                zoneSettings.FolderItems.Add(new FactoryFileElement("~/zone_data.csv", "text/csv"));
                zoneSettings.Directory = "../Data/heightmaps";
                b.Sections.Remove("Saga.Factory.Zones");
                b.Sections.Add("Saga.Factory.Zones", zoneSettings);

                //ITEMS
                ItemSettings itemSettings = new ItemSettings();
                itemSettings.FolderItems.Add(new FactoryFileElement("~/item_data.xml", "text/xml"));
                b.Sections.Remove("Saga.Factory.Items");
                b.Sections.Add("Saga.Factory.Items", itemSettings);

                //WEAPONARY
                WeaponarySettings weaponarySettings = new WeaponarySettings();
                weaponarySettings.FolderItems.Add(new FactoryFileElement("~/weapon_data.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.Weaponary");
                b.Sections.Add("Saga.Factory.Weaponary", weaponarySettings);

                //SPAWNTEMPLATE
                SpawntemplateSettings spawntemplateSettings = new SpawntemplateSettings();
                spawntemplateSettings.FolderItems.Add(new FactoryFileElement("~/npc_templates.csv", "text/csv"));
                spawntemplateSettings.FolderItems.Add(new FactoryFileElement("~/item_templates.csv", "text/csv"));
                b.Sections.Remove("Saga.Factory.SpawnTemplate");
                b.Sections.Add("Saga.Factory.SpawnTemplate", spawntemplateSettings);

                //SPAWNS NPC & MAP
                SpawnWorldObjectSettings spawnworldobjectSettings = new SpawnWorldObjectSettings();
                spawnworldobjectSettings.FolderItems.Add(new FactoryFileElement("~/npc-spawns/", "text/csv"));
                spawnworldobjectSettings.FolderItems.Add(new FactoryFileElement("~/item-spawns/", "text/csv"));
                spawnworldobjectSettings.DerivedType = worldspawn;
                b.Sections.Remove("Saga.Factory.SpawnWorldObjects");
                b.Sections.Add("Saga.Factory.SpawnWorldObjects", spawnworldobjectSettings);

                //SPAWNS MOBS
                SpawnMultiWorldObjectSettings spawnmultiworldobjectSettings = new SpawnMultiWorldObjectSettings();
                spawnmultiworldobjectSettings.FolderItems.Add(new FactoryFileElement("~/mob-spawns/", "text/csv"));
                spawnmultiworldobjectSettings.DerivedType = multiworldspawn;
                b.Sections.Remove("Saga.Factory.SpawnMultiWorldObjects");
                b.Sections.Add("Saga.Factory.SpawnMultiWorldObjects", spawnmultiworldobjectSettings);

                //SCRIPTING
                ScriptingSettings scriptingSettings = new ScriptingSettings();
                scriptingSettings.Directory = "../Saga.Scripting";
                scriptingSettings.Assemblies.Add(new FactoryFileElement("System.dll", "text/csv"));
                scriptingSettings.Assemblies.Add(new FactoryFileElement("System.Data.dll", "text/csv"));
                scriptingSettings.Assemblies.Add(new FactoryFileElement("System.Xml.dll", "text/csv"));
                b.Sections.Remove("Saga.Manager.Scripting");
                b.Sections.Add("Saga.Manager.Scripting", scriptingSettings);

                //EVENTS
                EventSettings eventSettings = new EventSettings();
                eventSettings.FolderItems.Add(new FactoryFileElement("~/eventlist.csv", "text/csv"));
                eventSettings.Provider = eventprovider;
                b.Sections.Remove("Saga.Factory.Events");
                b.Sections.Add("Saga.Factory.Events", eventSettings);

                //QUUESTS
                QuestSettings questSettings = new QuestSettings();
                questSettings.Directory = "../Quests/";
                questSettings.SDirectory = "~/Scenario.Quests/";
                questSettings.Provider = questplugin;
                questSettings.ScenarioProvider = scenarioquestplugin;
                b.Sections.Remove("Saga.Manager.Quest");
                b.Sections.Add("Saga.Manager.Quest", questSettings);

                //DATABASE SETTINGS
                DatabaseSettings databaseSettings = new DatabaseSettings();
                databaseSettings.Database = databasename;
                databaseSettings.Username = databaseusername;
                databaseSettings.Password = databasepassword;
                databaseSettings.Port = dbport;
                databaseSettings.Host = dbhost;
                databaseSettings.DBType = dbprovider;
                b.Sections.Remove("Saga.Manager.Database");
                b.Sections.Add("Saga.Manager.Database", databaseSettings);

                //SAVE CONFIGURATION AND REFRESH ALL SECTIONS
                b.Save();

                //REFRESH ALL SECTIONS
                ConfigurationManager.RefreshSection("Saga.Factory.SpawnMultiWorldObjects");
                ConfigurationManager.RefreshSection("Saga.Manager.Database");
                ConfigurationManager.RefreshSection("Saga.Manager.Quest");
                ConfigurationManager.RefreshSection("Saga.Manager.Scripting");
                ConfigurationManager.RefreshSection("Saga.Factory.Events");
                ConfigurationManager.RefreshSection("Saga.Factory.SpawnWorldObject");
                ConfigurationManager.RefreshSection("Saga.ServerVars");
                ConfigurationManager.RefreshSection("Saga.Manager.NetworkSettings");
                ConfigurationManager.RefreshSection("Saga.Manager.ConsoleSettings");
                ConfigurationManager.RefreshSection("Saga.Factory.Portals");
                ConfigurationManager.RefreshSection("Saga.Factory.CharacterConfiguration");
                ConfigurationManager.RefreshSection("Saga.Factory.Addition");
                ConfigurationManager.RefreshSection("Saga.Factory.Spells");
                ConfigurationManager.RefreshSection("Saga.Factory.StatusByLevel");
                ConfigurationManager.RefreshSection("Saga.Factory.Warps");
                ConfigurationManager.RefreshSection("Saga.Factory.Zones");
                ConfigurationManager.RefreshSection("Saga.Factory.Items");
                ConfigurationManager.RefreshSection("Saga.Factory.Weaponary");
                ConfigurationManager.RefreshSection("Saga.Factory.SpawnTemplate");

                Console.WriteLine("Everything configured");
            }
        }