Пример #1
0
        /// <summary>
        /// Dumps all configuration options to a text file in Markdown format
        /// </summary>
        public static void DumpDescriptions()
        {
            var sb = new StringBuilder();
            var defaults = new ConfigFile();

            foreach (var field in defaults.GetType().GetFields().OrderBy(f => f.Name))
            {
                if (field.IsStatic)
                    continue;

                var name = field.Name;
                var type = field.FieldType.Name;

                var descattr =
                    field.GetCustomAttributes(false).FirstOrDefault(o => o is DescriptionAttribute) as DescriptionAttribute;
                var desc = descattr != null && !string.IsNullOrWhiteSpace(descattr.Description) ? descattr.Description : "None";

                var def = field.GetValue(defaults);

                sb.AppendLine("## {0}  ".SFormat(name));
                sb.AppendLine("**Type:** {0}  ".SFormat(type));
                sb.AppendLine("**Description:** {0}  ".SFormat(desc));
                sb.AppendLine("**Default:** \"{0}\"  ".SFormat(def));
                sb.AppendLine();
            }

            File.WriteAllText("ConfigDescriptions.txt", sb.ToString());
        }
Пример #2
0
        public void OnConfigRead(ConfigFile file)
        {
            NPC.defaultMaxSpawns = file.DefaultMaximumSpawns;
            NPC.defaultSpawnRate = file.DefaultSpawnRate;

            Main.autoSave = file.AutoSave;
            if (Backups != null)
            {
                Backups.KeepFor = file.BackupKeepFor;
                Backups.Interval = file.BackupInterval;
            }
            if (!OverridePort)
            {
                Netplay.serverPort = file.ServerPort;
            }

            if (file.MaxSlots > 235)
                file.MaxSlots = 235;
            Main.maxNetPlayers = file.MaxSlots + 20;
            Netplay.password = "";
            Netplay.spamCheck = false;

            RconHandler.Password = file.RconPassword;
            RconHandler.ListenPort = file.RconPort;

            Utils.HashAlgo = file.HashAlgorithm;

            file.ServerName = file.ServerNickname;
        }
Пример #3
0
        public TPulse(Main game)
            : base(game)
        {
            Config = new ConfigFile();
            Order = 0;
            Players = new TPPlayer[Main.maxPlayers];

            PlugInHandler.AddPlugIn(this);

            Commands = new Commands(this);
            ServerHandle = new ServerHandler(this);
            PlayerHandle = new PlayerHandler(this);
        }
Пример #4
0
 //That bizarre... need to reread this stack
 public TSRestPlayer(ConfigFile config)
     : base(config.SuperAdminChatRGB, config.SuperAdminChatPrefix, config.SuperAdminChatSuffix)
 {
     Group = new SuperAdminGroup(config.SuperAdminChatRGB, config.SuperAdminChatPrefix, config.SuperAdminChatSuffix);
     AwaitingResponse = new Dictionary<string, Action<object>>();
 }