Beispiel #1
0
 public void funcCmd(CommandArgs e)
 {
     if (e.Parameters.Count < 1)
     {
         e.Player.SendMessage("[AntiSpamBot] Please do /antispambot help", Color.Silver);
         return;
     }
     else
     {
         if (e.Parameters[0] == "help" || e.Parameters[0] == "reload")
         {
             if (e.Parameters[0] == "help")
             {
                 e.Player.SendMessage("[AntiSpamBot] Commands:", Color.Green);
                 e.Player.SendMessage("/antispambot reload", Color.Silver);
                 e.Player.SendMessage("/antispambot help", Color.Silver);
                 return;
             }
             if (e.Parameters[0] == "reload")
             {
                 string path = Path.Combine(TShock.SavePath, "AntiSpamBot.json");
                 Config = Config.Read(path);
                 if (!File.Exists(path))
                 {
                     Config.Write(path);
                 }
                 vars.Message1 = Config.Message1;
                 vars.Message2 = Config.Message2;
                 vars.Permission = Config.Permission;
                 vars.Time = Config.Time;
                 vars.EnableMessages = Config.EnableMessages;
                 vars.Enable = Config.Enable;
                 vars.cmdPermission = Config.cmdPermission;
                 e.Player.SendMessage("[AntiSpamBot] Plugin has been successfully reloaded.", Color.Green);
                 return;
             }
         }
         else
         {
             e.Player.SendMessage("[AntiSpamBot] Please do /antispambot help", Color.Silver);
             return;
         }
     }
 }
Beispiel #2
0
        public override void Initialize()
        {
            string path = Path.Combine(TShock.SavePath, "AntiSpamBot.json");
            Config = Config.Read(path);
            if (!File.Exists(path))
            {
                Config.Write(path);
            }

            vars.Message1 = Config.Message1;
            vars.Message2 = Config.Message2;
            vars.Permission = Config.Permission;
            vars.Time = Config.Time;
            vars.Enable = Config.Enable;
            vars.EnableMessages = Config.EnableMessages;
            vars.cmdPermission = Config.cmdPermission;

            Commands.ChatCommands.Add(new Command(vars.cmdPermission, funcCmd, "antispambot"));
            ServerApi.Hooks.ServerChat.Register(this, onChat);
        }