Ejemplo n.º 1
0
        /// <summary>
        /// Sets up the configuration file for all variables, and creates any missing files.
        /// </summary>
        public static void SetupConfig()
        {
            if (!Directory.Exists(TShock.SavePath))
            {
                Directory.CreateDirectory(TShock.SavePath);
            }

            CreateIfNot(RulesPath, "Respect the admins!\nDon't use TNT!");
            CreateIfNot(MotdPath,
                        "This server is running TShock for Terraria.\n Type /help for a list of commands.\n%255,000,000%Current map: %map%\nCurrent players: %players%");
            CreateIfNot(WhitelistPath);
            if (File.Exists(ConfigPath))
            {
                TShock.Config = ConfigFile.Read(ConfigPath);
                // Add all the missing config properties in the json file
            }
            TShock.Config.Write(ConfigPath);

            if (File.Exists(ServerSideCharacterConfigPath))
            {
                TShock.ServerSideCharacterConfig = ServerSideConfig.Read(ServerSideCharacterConfigPath);
                // Add all the missing config properties in the json file
            }
            TShock.ServerSideCharacterConfig.Write(ServerSideCharacterConfigPath);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Sets up the configuration file for all variables, and creates any missing files.
        /// </summary>
        public static void SetupConfig()
        {
            if (!Directory.Exists(TShock.SavePath))
            {
                Directory.CreateDirectory(TShock.SavePath);
            }

            CreateIfNot(RulesPath, "Respect the admins!\nDon't use TNT!");
            CreateIfNot(MotdPath, MotdFormat);

            CreateIfNot(WhitelistPath);
            if (File.Exists(ConfigPath))
            {
                TShock.Config = ConfigFile.Read(ConfigPath);
                // Add all the missing config properties in the json file
            }
            TShock.Config.Write(ConfigPath);

            if (File.Exists(ServerSideCharacterConfigPath))
            {
                TShock.ServerSideCharacterConfig = ServerSideConfig.Read(ServerSideCharacterConfigPath);
                // Add all the missing config properties in the json file
            }
            else
            {
                TShock.ServerSideCharacterConfig = new ServerSideConfig
                {
                    StartingInventory =
                        new List <NetItem>()
                    {
                        new NetItem()
                        {
                            netID = -15, stack = 1, prefix = 0
                        },
                        new NetItem()
                        {
                            netID = -13, stack = 1, prefix = 0
                        },
                        new NetItem()
                        {
                            netID = -16, stack = 1, prefix = 0
                        }
                    }
                };
            }
            TShock.ServerSideCharacterConfig.Write(ServerSideCharacterConfigPath);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Sets up the configuration file for all variables, and creates any missing files.
        /// </summary>
        public static void SetupConfig()
        {
            if (!Directory.Exists(TShock.SavePath))
            {
                Directory.CreateDirectory(TShock.SavePath);
            }

            CreateIfNot(RulesPath, "Respect the admins!\nDon't use TNT!");
            CreateIfNot(MotdPath, MotdFormat);

            CreateIfNot(WhitelistPath);
            bool writeConfig = true;             // Default to true if the file doesn't exist

            if (File.Exists(ConfigPath))
            {
                TShock.Config = ConfigFile.Read(ConfigPath, out writeConfig);
            }
            if (writeConfig)
            {
                // Add all the missing config properties in the json file
                TShock.Config.Write(ConfigPath);
            }

            bool writeSSCConfig = true;             // Default to true if the file doesn't exist

            if (File.Exists(ServerSideCharacterConfigPath))
            {
                TShock.ServerSideCharacterConfig =
                    ServerSideConfig.Read(ServerSideCharacterConfigPath, out writeSSCConfig);
            }
            if (writeSSCConfig)
            {
                // Add all the missing config properties in the json file
                TShock.ServerSideCharacterConfig = new ServerSideConfig
                {
                    StartingInventory =
                        new List <NetItem>
                    {
                        new NetItem(-15, 1, 0),
                        new NetItem(-13, 1, 0),
                        new NetItem(-16, 1, 0)
                    }
                };
                TShock.ServerSideCharacterConfig.Write(ServerSideCharacterConfigPath);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Sets up the configuration file for all variables, and creates any missing files.
        /// </summary>
        public static void SetupConfig()
        {
            if (!Directory.Exists(TShock.SavePath))
            {
                Directory.CreateDirectory(TShock.SavePath);
            }

            CreateIfNot(RulesPath, "玩家和睦相处!\n禁止使用爆炸物.");
            CreateIfNot(MotdPath, MotdFormat);

            CreateIfNot(WhitelistPath);
            if (File.Exists(ConfigPath))
            {
                TShock.Config = ConfigFile.Read(ConfigPath);
                // Add all the missing config properties in the json file
            }
            TShock.Config.Write(ConfigPath);

            if (File.Exists(ServerSideCharacterConfigPath))
            {
                TShock.ServerSideCharacterConfig = ServerSideConfig.Read(ServerSideCharacterConfigPath);
                // Add all the missing config properties in the json file
            }
            else
            {
                TShock.ServerSideCharacterConfig = new ServerSideConfig
                {
                    StartingInventory =
                        new List <NetItem>
                    {
                        new NetItem(-15, 1, 0),
                        new NetItem(-13, 1, 0),
                        new NetItem(-16, 1, 0)
                    }
                };
            }
            TShock.ServerSideCharacterConfig.Write(ServerSideCharacterConfigPath);
        }
        public static void DumpDescriptions(bool SSCconfigFile)
        {
            ConfigDescription.Clear();

            if (SSCconfigFile)
            {
                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;
                    string desc = descattr != null && !string.IsNullOrWhiteSpace(descattr.Description) ? descattr.Description : "None";

                    var def = field.GetValue(defaults);
                    Dictionary <string, string> definition = new Dictionary <string, string> {
                    };
                    definition.Add("type", type);
                    //               desc = desc.Replace("\"", "");
                    definition.Add("definition", desc);

                    definition.Add("default", def.ToString());
                    ConfigDescription.Add(name, definition);
                }
            }
            else
            {
                var defaults = new ServerSideConfig();
                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;
                    string desc = descattr != null && !string.IsNullOrWhiteSpace(descattr.Description) ? descattr.Description : "None";

                    var def = field.GetValue(defaults);
                    Dictionary <string, string> definition = new Dictionary <string, string> {
                    };
                    definition.Add("type", type);
                    //               desc = desc.Replace("\"", "");
                    definition.Add("definition", desc);

                    definition.Add("default", def.ToString());
                    ConfigDescription.Add(name, definition);
                }
            }
        }