Esempio n. 1
0
 private static void SetupProperties()
 {
     properties = new ServerProperties("server.properties");
     properties.Load();
     properties.pushData();
     properties.Save();
 }
        private static void SetupProperties()
        {
            properties = new ServerProperties("server.properties");
            properties.Load();

            properties.AddHeaderLine("TDSM Properties File.");
            properties.AddHeaderLine("Rejected items need to be seperated by commas ','");
            properties.AddHeaderLine("For other help visit http://wiki.tdsm.org");

            properties.pushData();
            properties.Save(false);
        }
 static void setupProperties()
 {
     properties = new ServerProperties("server.properties");
     properties.Load();
     properties.pushData();
     properties.Save();
 }
        private static void SetupProperties()
        {
            properties = new ServerProperties("server.properties");
            properties.Load();

            properties.AddHeaderLine("TDSM Properties File.");
            properties.AddHeaderLine("Rejected items need to be seperated by commas ','");
            properties.AddHeaderLine("For other help visit http://wiki.tdsm.org");

            properties.pushData();
            properties.Save(false);
        }
Esempio n. 5
0
        public static void ParseArgs(string[] args)
        {
            if (args != null && args.Length > 0)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    if (i == (args.Length - 1))
                    {
                        break;
                    }
                    string commandMessage = args[i].ToLower().Trim();
                    // 0 for Ops
                    if (commandMessage.Equals("-ignoremessages:0"))
                    {
                        Statics.cmdMessages = false;
                    }
                    else if (commandMessage.Equals("-maxplayers"))
                    {
                        try
                        {
                            properties.MaxPlayers = Convert.ToInt32(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-ip"))
                    {
                        properties.ServerIP = args[i + 1];
                    }
                    else if (commandMessage.Equals("-port"))
                    {
                        try
                        {
                            properties.Port = Convert.ToInt32(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-greeting"))
                    {
                        properties.Greeting = args[i + 1];
                    }
                    else if (commandMessage.Equals("-worldpath"))
                    {
                        properties.WorldPath = args[i + 1];
                    }
                    else if (commandMessage.Equals("-password"))
                    {
                        properties.Password = args[i + 1];
                    }
                    else if (commandMessage.Equals("-allowupdates"))
                    {
                        try
                        {
                            properties.AutomaticUpdates = Convert.ToBoolean(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-npcdoorcancel"))
                    {
                        try
                        {
                            properties.NPCDoorOpenCancel = Convert.ToBoolean(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-seed"))
                    {
                        try
                        {
                            properties.Seed = args[i + 1];
                        }
                        catch (Exception)
                        {
                        }
                    }
                    else if (commandMessage.Equals("-mapsize"))
                    {
                        properties.MapSize = args[i + 1];
                    }
                    else if (commandMessage.Equals("-usecustomtiles"))
                    {
                        try
                        {
                            properties.UseCustomTiles = Convert.ToBoolean(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-maxtilesx"))
                    {
                        try
                        {
                            properties.MaxTilesX = Convert.ToInt32(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-maxtilesy"))
                    {
                        try
                        {
                            properties.MaxTilesY = Convert.ToInt32(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-numdungeons"))
                    {
                        try
                        {
                            properties.DungeonAmount = Convert.ToInt32(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-customworldgen"))
                    {
                        try
                        {
                            properties.UseCustomGenOpts = Convert.ToBoolean(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-numislands"))
                    {
                        try
                        {
                            properties.FloatingIslandAmount = Convert.ToInt32(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-whitelist"))
                    {
                        try
                        {
                            properties.UseWhiteList = Convert.ToBoolean(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-pidfile"))
                    {
                        try
                        {
                            properties.PIDFile = args[i + 1];
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-simpleloop"))
                    {
                        try
                        {
                            properties.SimpleLoop = Convert.ToBoolean(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-windowsoutput"))
                    {
                        Platform.Type = Platform.PlatformType.WINDOWS;
                        try
                        {
                            bool windows = Convert.ToBoolean(args[i + 1]);
                            if (!windows)
                            {
                                Platform.Type = Platform.PlatformType.LINUX;
                            }
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-hackeddata"))
                    {
                        try
                        {
                            properties.HackedData = Convert.ToBoolean(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-rconip"))
                    {
                        try
                        {
                            properties.RConBindAddress = args[i + 1];
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-rconsalt"))
                    {
                        try
                        {
                            properties.RConHashNonce = args[i + 1];
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-rotatelog"))
                    {
                        try
                        {
                            properties.LogRotation = Convert.ToBoolean(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }
                    else if (commandMessage.Equals("-spawnnpcmax"))
                    {
                        try
                        {
                            properties.SpawnNPCMax = Convert.ToInt16(args[i + 1]);
                        }
                        catch
                        {
                        }
                    }

                    //explosions
                    //rejectplayeritems
                }

                properties.Save();
            }
        }
        public static void ParseArgs(string[] args)
        {
            try
            {
                if (args != null && args.Length > 0)
                {
                    for (int i = 0; i < args.Length; i++)
                    {
                        //if (i == (args.Length - 1) && args.Length > 1) { break; }
                        string commandMessage = args[i].ToLower().Trim();
                        // 0 for Ops
                        if (commandMessage.Equals("-ignoremessages:0"))
                        {
                            Statics.cmdMessages = false;
                        }
                        else if (commandMessage.Equals("-maxplayers"))
                        {
                            int val;
                            if (Int32.TryParse(args[i + 1], out val))
                            {
                                properties.MaxPlayers = val;
                            }
                        }
                        else if (commandMessage.Equals("-ip"))
                        {
                            properties.ServerIP = args[i + 1];
                        }
                        else if (commandMessage.Equals("-port"))
                        {
                            int val;
                            if (Int32.TryParse(args[i + 1], out val))
                            {
                                properties.Port = val;
                            }
                        }
                        else if (commandMessage.Equals("-greeting"))
                        {
                            properties.Greeting = args[i + 1];
                        }
                        else if (commandMessage.Equals("-worldpath"))
                        {
                            properties.WorldPath = args[i + 1];
                        }
                        else if (commandMessage.Equals("-password"))
                        {
                            properties.Password = args[i + 1];
                        }
                        else if (commandMessage.Equals("-allowupdates"))
                        {
                            bool val;
                            if (Boolean.TryParse(args[i + 1], out val))
                            {
                                properties.AutomaticUpdates = val;
                            }
                        }
                        else if (commandMessage.Equals("-npcdoorcancel"))
                        {
                            bool val;
                            if (Boolean.TryParse(args[i + 1], out val))
                            {
                                properties.NPCDoorOpenCancel = val;
                            }
                        }
                        else if (commandMessage.Equals("-seed"))
                        {
                            try
                            {
                                properties.Seed = args[i + 1];
                            }
                            catch (Exception)
                            { }
                        }
                        else if (commandMessage.Equals("-mapsize"))
                        {
                            properties.MapSize = args[i + 1];
                        }
                        else if (commandMessage.Equals("-usecustomtiles"))
                        {
                            bool val;
                            if (Boolean.TryParse(args[i + 1], out val))
                            {
                                properties.UseCustomTiles = val;
                            }
                        }
                        else if (commandMessage.Equals("-maxtilesx"))
                        {
                            int val;
                            if (Int32.TryParse(args[i + 1], out val))
                            {
                                properties.MaxTilesX = val;
                            }
                        }
                        else if (commandMessage.Equals("-maxtilesy"))
                        {
                            int val;
                            if (Int32.TryParse(args[i + 1], out val))
                            {
                                properties.MaxTilesY = val;
                            }
                        }
                        else if (commandMessage.Equals("-numdungeons"))
                        {
                            int val;
                            if (Int32.TryParse(args[i + 1], out val))
                            {
                                properties.DungeonAmount = val;
                            }
                        }
                        else if (commandMessage.Equals("-customworldgen"))
                        {
                            bool val;
                            if (Boolean.TryParse(args[i + 1], out val))
                            {
                                properties.UseCustomGenOpts = val;
                            }
                        }
                        else if (commandMessage.Equals("-numislands"))
                        {
                            int val;
                            if (Int32.TryParse(args[i + 1], out val))
                            {
                                properties.FloatingIslandAmount = val;
                            }
                        }
                        else if (commandMessage.Equals("-whitelist"))
                        {
                            bool val;
                            if (Boolean.TryParse(args[i + 1], out val))
                            {
                                properties.UseWhiteList = val;
                            }
                        }
                        else if (commandMessage.Equals("-pidfile"))
                        {
                            try
                            {
                                properties.PIDFile = args[i + 1];
                            }
                            catch { }
                        }
                        else if (commandMessage.Equals("-simpleloop"))
                        {
                            bool val;
                            if (Boolean.TryParse(args[i + 1], out val))
                            {
                                properties.SimpleLoop = val;
                            }
                        }
                        else if (commandMessage.Equals("-windowsoutput"))
                        {
                            Platform.Type = Platform.PlatformType.WINDOWS;
                            bool val;
                            if (Boolean.TryParse(args[i + 1], out val) && !val)
                            {
                                Platform.Type = Platform.PlatformType.LINUX;
                            }
                        }
                        else if (commandMessage.Equals("-hackeddata"))
                        {
                            bool val;
                            if (Boolean.TryParse(args[i + 1], out val))
                            {
                                properties.HackedData = val;
                            }
                        }
                        else if (commandMessage.Equals("-rconip"))
                        {
                            try
                            {
                                properties.RConBindAddress = args[i + 1];
                            }
                            catch { }
                        }
                        else if (commandMessage.Equals("-rconsalt"))
                        {
                            try
                            {
                                properties.RConHashNonce = args[i + 1];
                            }
                            catch { }
                        }
                        else if (commandMessage.Equals("-rotatelog"))
                        {
                            bool val;
                            if (Boolean.TryParse(args[i + 1], out val))
                            {
                                properties.LogRotation = val;
                            }
                        }
                        else if (commandMessage.Equals("-spawnnpcmax"))
                        {
                            int val;
                            if (Int32.TryParse(args[i + 1], out val))
                            {
                                properties.SpawnNPCMax = val;
                            }
                        }
                        else if (commandMessage.Equals("-disablemaxplayers"))
                        {
                            SlotManager.MaxPlayersDisabled = true;
                        }
                        else if (commandMessage.Equals("-allowexplosions"))
                        {
                            bool val;
                            if (Boolean.TryParse(args[i + 1], out val))
                            {
                                properties.AllowExplosions = val;
                            }
                        }
                        else if (commandMessage.Equals("-rejectitems"))
                        {
                            properties.RejectedItems = args[i + 1];
                        }
                    }

                    properties.Save();
                }
            }
            catch (Exception e)
            {
                ProgramLog.Log(e);
            }
        }