示例#1
0
        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
文件: TShock.cs 项目: InanZen/TShock
 public TShock(Main game)
     : base(game)
 {
     Config = new ConfigFile();
     Order = 0;
 }
示例#3
0
文件: TShock.cs 项目: InanZen/TShock
        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;
        }
示例#4
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;
            }

            Netplay.spamCheck = file.SpamChecks;

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

            Tools.HashAlgo = file.HashAlgorithm;
        }
示例#5
0
文件: TShock.cs 项目: B-BOB/TShock
 /// <summary>TShock - The constructor for the TShock plugin.</summary>
 /// <param name="game">game - The Terraria main game.</param>
 public TShock(Main game)
     : base(game)
 {
     Config = new ConfigFile();
     ServerSideCharacterConfig = new ServerSideConfig();
     ServerSideCharacterConfig.StartingInventory.Add(new NetItem(-15, 1, 0));
     ServerSideCharacterConfig.StartingInventory.Add(new NetItem(-13, 1, 0));
     ServerSideCharacterConfig.StartingInventory.Add(new NetItem(-16, 1, 0));
     Order = 0;
     instance = this;
 }
示例#6
0
 public TShock(Main game)
     : base(game)
 {
     Config = new ConfigFile();
     ServerSideCharacterConfig = new ServerSideConfig();
     ServerSideCharacterConfig.StartingInventory.Add(new NetItem { netID = -15, prefix = 0, stack = 1 });
     ServerSideCharacterConfig.StartingInventory.Add(new NetItem { netID = -13, prefix = 0, stack = 1 });
     ServerSideCharacterConfig.StartingInventory.Add(new NetItem { netID = -16, prefix = 0, stack = 1 });
     Order = 0;
     instance = this;
 }
示例#7
0
        public void OnConfigRead(ConfigFile file)
        {
            NPC.maxSpawns = file.DefaultMaximumSpawns;
            NPC.defaultSpawnRate = file.DefaultSpawnRate;

            Main.autoSave = file.AutoSave;
            Backups.KeepFor = file.BackupKeepFor;
            Backups.Interval = file.BackupInterval;

            Netplay.serverPort = file.ServerPort;

            Netplay.spamCheck = file.SpamChecks;
        }
示例#8
0
 public static void WriteJsonConfiguration()
 {
     ConfigFile cfg = new ConfigFile();
     cfg.InvasionMultiplier = InvasionMultiplier;
     cfg.DefaultMaximumSpawns = DefaultMaxSpawns;
     cfg.DefaultSpawnRate = DefaultSpawnRate;
     cfg.ServerPort = ServerPort;
     cfg.EnableWhitelist = EnableWhitelist;
     cfg.InfiniteInvasion = InfiniteInvasion;
     cfg.AlwaysPvP = PermaPvp;
     cfg.KickCheaters = KickCheater;
     cfg.BanCheaters = BanCheater;
     cfg.KickGriefers = KickGriefer;
     cfg.BanGriefers = BanGriefer;
     cfg.BanKillTileAbusers = BanTnt;
     cfg.KickKillTileAbusers = KickTnt;
     cfg.BanExplosives = BanBoom;
     cfg.KickExplosives = KickBoom;
     cfg.DisableExplosives = DisableBoom;
     cfg.SpawnProtection = SpawnProtect;
     cfg.SpawnProtectionRadius = SpawnProtectRadius;
     cfg.MaxSlots = MaxSlots;
     cfg.RangeChecks = RangeChecks;
     cfg.SpamChecks = SpamChecks;
     cfg.DisableBuild = DisableBuild;
     cfg.TileThreshold = TileThreshold;
     cfg.AdminChatRGB = AdminChatRGB;
     cfg.AdminChatPrefix = AdminChatPrefix;
     cfg.PvpThrottle = PvpThrottle;
     cfg.BackupInterval = BackupInterval;
     cfg.BackupKeepFor = BackupKeepFor;
     cfg.RememberLeavePos = RememberLeavePos;
     cfg.HardcoreOnly = HardcoreOnly;
     cfg.BanOnHardcoreOnlyDeath = BanOnHardcoreDeath;
     cfg.KickOnHardcoreOnlyDeath = KickOnHardcoreDeath;
     cfg.AutoSave = AutoSave;
     string json = JsonConvert.SerializeObject(cfg, Formatting.Indented);
     TextWriter tr = new StreamWriter(FileTools.ConfigPath);
     tr.Write(json);
     tr.Close();
 }
示例#9
0
        public static void WriteJsonConfiguration()
        {
            if (!Directory.Exists(FileTools.SaveDir))
            {
                Directory.CreateDirectory(FileTools.SaveDir);
            }
            if (File.Exists(FileTools.SaveDir + "config.json"))
            {
                return;
            }
            FileTools.CreateFile(FileTools.SaveDir + "config.json");
            ConfigFile cfg = new ConfigFile();
            cfg.InvasionMultiplier = 50;
            cfg.DefaultMaximumSpawns = 4;
            cfg.DefaultSpawnRate = 700;
            cfg.ServerPort = 7777;
            cfg.EnableWhitelist = false;
            cfg.InfiniteInvasion = false;
            cfg.AlwaysPvP = false;
            cfg.KickCheaters = kickCheater;
            cfg.BanCheaters = banCheater;
            cfg.KickGriefers = kickGriefer;
            cfg.BanGriefers = banGriefer;
            cfg.BanKillTileAbusers = true;
            cfg.KickKillTileAbusers = true;
            cfg.BanExplosives = true;
            cfg.KickExplosives = true;
            cfg.SpawnProtection = true;
            cfg.SpawnProtectionRadius = 5;
            cfg.MaxSlots = maxSlots;

            string json = JsonConvert.SerializeObject(cfg, Formatting.Indented);
            TextWriter tr = new StreamWriter(FileTools.SaveDir + "config.json");
            tr.Write(json);
            tr.Close();
        }
示例#10
0
 public TShock(Main game)
     : base(game)
 {
     Config = new ConfigFile();
     Order  = 0;
 }