Example #1
0
 public static ABConfig Read(string file)
 {
     if (!File.Exists(file))
     {
         ABConfig.WriteExample(file);
     }
     return(JsonConvert.DeserializeObject <ABConfig>(File.ReadAllText(file)));
 }
Example #2
0
 public void autobc(CommandArgs args)
 {
     try
     {
         Config = ABConfig.Read(ConfigPath).Write(ConfigPath);
         args.Player.SendSuccessMessage("Successfully reloaded AutoBroadcast config!");
     }
     catch (Exception ex)
     {
         Config = new ABConfig();
         args.Player.SendWarningMessage("An exception occurred while parsing the AutoBroadcast config! check logs for more details!");
         Log.Error("[AutoBroadcast] An exception occurred while parsing tbe AutoBroadcast config!\n{0}".SFormat(ex.ToString()));
     }
 }
Example #3
0
        public void OnInitialize(EventArgs args)
        {
            Commands.ChatCommands.Add(new Command("abroadcast", autobc, "autobc"));

            try
            {
                Config = ABConfig.Read(ConfigPath).Write(ConfigPath);
            }
            catch (Exception ex)
            {
                Config = new ABConfig();
                Log.ConsoleError("[AutoBroadcast] An exception occurred while parsing the AutoBroadcast config!\n{0}".SFormat(ex.ToString()));
            }
        }
 public void AutoBC(ReloadEventArgs args)
 {
     try
     {
         Config = ABConfig.Read(ConfigPath).Write(ConfigPath);
         TShock.Log.Info("Successfully reloaded AutoBroadcast config!");
     }
     catch (Exception ex)
     {
         Config = new ABConfig();
         args.Player.SendWarningMessage("An exception occurred while parsing the AutoBroadcast config! check logs for more details!");
         TShock.Log.ConsoleError("[AutoBroadcast] An exception occurred while parsing the AutoBroadcast config!\n{0}".SFormat(ex.ToString()));
     }
 }
 public void OnInitialize(EventArgs args)
 {
     try
     {
         Config = ABConfig.Read(ConfigPath).Write(ConfigPath);
     }
     catch (Exception ex)
     {
         Config = new ABConfig();
         TShock.Log.ConsoleError("[AutoBroadcast] An exception occurred while parsing the AutoBroadcast config!\n{0}".SFormat(ex.ToString()));
     }
     Update.Elapsed += OnUpdate;
     Update.Start();
 }
Example #6
0
        public static void WriteExample(string file)
        {
            var Ex = new Broadcast();
            Ex.Name = "Example Broadcast";
            Ex.Enabled = false;
            Ex.Messages = new string[]
            {
                "This is an example broadcast",
                "It will broadcast every 5 minutes",
                "Broadcasts can also execute commands",
                "/time noon"
            };
            Ex.ColorRGB = new float[] { 255f, 0f, 0f };
            Ex.Interval = 300;
            Ex.StartDelay = 60;

            var Conf = new ABConfig();
            Conf.Broadcasts = new Broadcast[] { Ex };

            Conf.Write(file);
        }
Example #7
0
        public static void WriteExample(string file)
        {
            var Ex = new Broadcast();

            Ex.Name     = "Example Broadcast";
            Ex.Enabled  = false;
            Ex.Messages = new string[]
            {
                "This is an example broadcast",
                "It will broadcast every 5 minutes",
                "Broadcasts can also execute commands",
                "/time noon"
            };
            Ex.ColorRGB   = new float[] { 255f, 0f, 0f };
            Ex.Interval   = 300;
            Ex.StartDelay = 60;

            var Conf = new ABConfig();

            Conf.Broadcasts = new Broadcast[] { Ex };

            Conf.Write(file);
        }
Example #8
0
        public void OnInitialize(EventArgs args)
        {
            Commands.ChatCommands.Add(new Command("abroadcast", autobc, "autobc"));

            try
            {
                Config = ABConfig.Read(ConfigPath).Write(ConfigPath);
            }
            catch (Exception ex)
            {
                Config = new ABConfig();
                TShock.Log.ConsoleError("[AutoBroadcast] An exception occurred while parsing the AutoBroadcast config!\n{0}".SFormat(ex.ToString()));
            }
        }
Example #9
0
 public void autobc(CommandArgs args)
 {
     try
     {
         Config = ABConfig.Read(ConfigPath).Write(ConfigPath);
         args.Player.SendSuccessMessage("Successfully reloaded AutoBroadcast config!");
     }
     catch (Exception ex)
     {
         Config = new ABConfig();
         args.Player.SendWarningMessage("An exception occurred while parsing the AutoBroadcast config! check logs for more details!");
         TShock.Log.Error("[AutoBroadcast] An exception occurred while parsing tbe AutoBroadcast config!\n{0}".SFormat(ex.ToString()));
     }
 }