示例#1
0
 public override void OnStart()
 {
     RegisterTask(new Spam(
                      messages, Setting.At(1).Get <int>(), Setting.At(2).Get <int>(),
                      Setting.At(3).Get <bool>(), !Setting.At(4).Get <bool>()
                      ));
 }
示例#2
0
        public override void OnStart()
        {
            var macro = new MacroSync();

            RegisterTask(new Mine(Setting.At(1).Get <BlockIdCollection>(), macro));
            RegisterTask(new InventoryMonitor(Setting.At(0).Get <string>(), macro));
        }
示例#3
0
 public override void OnStart()
 {
     RegisterTask(new Chat(
                      Setting.At(0).Get <string>().Split(' '),
                      Setting.At(1).Get <string>().Split(',').Select(x => x.First() == ' '?x.Skip(1).ToString():x).ToArray(), // If user enters ", " instead of "," remove the space.
                      Setting.At(2).Get <string>()));
 }
示例#4
0
 public override void OnStart()
 {
     RegisterTask(new Drink(
                      Setting.At(0).Get <bool>(), Setting.At(1).Get <bool>(), Setting.At(2).Get <bool>(),
                      Setting.At(3).Get <int>()
                      ));
 }
示例#5
0
 public override void OnStart()
 {
     // This should be used to register the tasks for the bot, see below.
     // (Note: called after 'OnEnable')
     RegisterTask(new Fetch(
                      Setting.At(0).Get <string>(), Setting.At(1).Get <string>().Split(new char[] { ',' })
                      ));
 }
示例#6
0
 public override void OnStart()
 {
     RegisterTask(new Fish(Setting.At(0).Get <bool>(), Setting.At(1).Get <int>(), Setting.At(2).Get <int>()));
     if (Setting.At(3).Get <bool>())
     {
         RegisterTask(new TNTDetector());
     }
 }
示例#7
0
        public override void OnStart()
        {
            var macroSync = new MacroSync(((IParentSetting)((IParentSetting)Setting.Get("Automation")).GetGroup(false).Get("On Inventory Full")).Get(2, "On Inventory Full Macro").Get <string>());
            var actionNr  = ((IParentSetting)Setting.Get("Automation")).GetValue <int>("On Inventory Full");

            RegisterTask(new Farm(Setting.At(0).Get <int>(), Setting.At(1).Get <int>(), (Mode)Setting.At(2).Get <int>(), actionNr == 0, macroSync));
            RegisterTask(new Store(actionNr, macroSync));
        }
示例#8
0
 public override void OnStart()
 {
     RegisterTask(new Eat(
                      Setting.At(1).Get <int>(), Setting.At(0).Get <int>(),
                      Setting.At(3).Get <bool>(),    // Can use soup.
                      Setting.At(2).Get <int>() == 1 // Determine mode.
                      ));
 }
示例#9
0
 public override PluginResponse OnEnable(IBotSettings botSettings)
 {
     // Called once the plugin is ticked in the plugin tab.
     if (string.IsNullOrWhiteSpace(Setting.At(0).Get <string>()))
     {
         return(new PluginResponse(false, "The Server must be set!"));
     }
     return(new PluginResponse(true));
 }
示例#10
0
        public override void OnStart()
        {
            var radius = new IRadius(Setting.At(0).Get <ILocation>(),
                                     Setting.At(1).Get <ILocation>());

            RegisterTask(new Print((Mode)Setting.At(2).Get <int>(), radius,
                                   Setting.At(3).Get <bool>(), Setting.At(4).Get <bool>())
                         );
        }
示例#11
0
        public override void OnStart()
        {
            var group = (IParentSetting)Setting.Get("Ore");
            var macro = new MacroSync();

            RegisterTask(new Tunnel(Setting.At(0).Get <int>(), PATTERNS[Setting.At(1).Get <int>()],
                                    group.GetValue <bool>("Diamond ore"), group.GetValue <bool>("Emerald ore"), group.GetValue <bool>("Iron ore"), group.GetValue <bool>("Gold ore"),
                                    group.GetValue <bool>("Redstone ore"), group.GetValue <bool>("Lapis Lazuli ore"), group.GetValue <bool>("Coal ore"), macro));
            RegisterTask(new InventoryMonitor(Setting.At(2).Get <string>(), macro));
        }
示例#12
0
 public override PluginResponse OnEnable(IBotSettings botSettings)
 {
     if (string.IsNullOrWhiteSpace(Setting.At(0).Get <string>()) || !File.Exists(Setting.At(0).Get <string>()))
     {
         return(new PluginResponse(false, "Invalid text file selected."));
     }
     messages = File.ReadAllLines(Setting.At(0).Get <string>());
     if (messages.Length == 0)
     {
         return(new PluginResponse(false, "Invalid text file selected."));
     }
     return(new PluginResponse(true));
 }
示例#13
0
 private string Format(IPermittedCredentials permittedCredentials)
 {
     if (Setting.At(2).Get <int>() == 0)
     {
         return(permittedCredentials.Email + ":" + permittedCredentials.Password);
     }
     if (Setting.At(2).Get <int>() == 1)
     {
         return(permittedCredentials.Email);
     }
     if (Setting.At(2).Get <int>() == 2)
     {
         return(permittedCredentials.Username);
     }
     throw new ArgumentException();
 }
示例#14
0
 public override PluginResponse OnEnable(IBotSettings botSettings)
 {
     if (!botSettings.loadWorld)
     {
         return(new PluginResponse(false, "'Load world' must be enabled."));
     }
     if (!botSettings.loadEntities || !botSettings.loadPlayers)
     {
         return(new PluginResponse(false, "'Load players' must be enabled."));
     }
     if (string.IsNullOrWhiteSpace(Setting.At(0).Get <string>()))
     {
         return(new PluginResponse(false, "Invalid owner name/uuid."));
     }
     return(new PluginResponse(true));
 }
示例#15
0
        public override PluginResponse OnEnable(IBotSettings botSettings)
        {
            if (!botSettings.loadWorld)
            {
                return(new PluginResponse(false, "'Load world' must be enabled."));
            }
            if (!botSettings.loadInventory)
            {
                return(new PluginResponse(false, "'Load inventory' must be enabled."));
            }
            if (Setting.At(0).Get <ILocation>().Compare(new Location(0, 0, 0)) &&
                Setting.At(1).Get <ILocation>().Compare(new Location(0, 0, 0)))
            {
                return(new PluginResponse(false, "No coordinates have been entered."));
            }

            return(new PluginResponse(true));
        }
示例#16
0
        public override PluginResponse OnEnable(IBotSettings botSettings)
        {
            // CLear the list in-case
            // it was restarted.
            AccountsSaved.Clear();

            // Request permissions to hook low level events.
            var permission = EventPermissions.CheckPermissions("low-level");

            if (permission == false)
            {
                return(new PluginResponse(false, "Not enough permissions, plugin requires 'All permissions'."));
            }
            EventPermissions.LowLevelHook("Ban checker", LowLevelEvents.OnServerInitialResponse, ServerResponse);

            bool exists = false;

            // Check if the files exist.
            if (!File.Exists(Setting.At(0).Get <string>()))
            {
                DiscordHelper.Alert("'Banned accounts' path not set.", 1);
            }
            else
            {
                exists = true;
            }
            if (!File.Exists(Setting.At(1).Get <string>()))
            {
                DiscordHelper.Alert("'Unbanned accounts' path not set.", 2);
            }
            else
            {
                exists = true;
            }

            if (!exists)
            {
                DiscordHelper.Error("No output paths have been set.", 1);
            }
            return(new PluginResponse(true));
        }
示例#17
0
        public override PluginResponse OnEnable(IBotSettings botSettings)
        {
            if (!botSettings.loadChat)
            {
                return(new PluginResponse(false, "'Load chat' must be enabled."));
            }
            if (string.IsNullOrWhiteSpace(Setting.At(0).Get <string>()))
            {
                return(new PluginResponse(false, "'Authorized Users' not set."));
            }
            if (string.IsNullOrWhiteSpace(Setting.At(1).Get <string>()))
            {
                return(new PluginResponse(false, "'Trigger Keywords' not set."));
            }
            if (string.IsNullOrWhiteSpace(Setting.At(2).Get <string>()))
            {
                return(new PluginResponse(false, "'Trigger Macro' not set."));
            }

            return(new PluginResponse(true));
        }
示例#18
0
        private void ServerResponse(IPermittedCredentials permittedCredentials, IPermittedServer permittedServer, IPermittedConnection connection)
        {
            // Check if this account has been
            // already checked.
            if (AccountsSaved.ContainsKey(permittedCredentials.Email))
            {
                return;                                                                   // Account already saved.
            }
            AccountsSaved.Add(permittedCredentials.Email, permittedCredentials.Password); // Add to list, so we don't save it twice.

            if (!connection.Connected)
            {
                if (File.Exists(Setting.At(0).Get <string>()))
                {
                    File.AppendAllText(Setting.At(0).Get <string>(), Environment.NewLine + Format(permittedCredentials));
                }
            }
            else if (File.Exists(Setting.At(1).Get <string>()))
            {
                File.AppendAllText(Setting.At(1).Get <string>(), Environment.NewLine + Format(permittedCredentials));
            }
        }
示例#19
0
        public override void OnStart()
        {
            var notificationsGroup = (IParentSetting)Setting.Get("Notifications");
            var miscellaneousGroup = (IParentSetting)Setting.Get("Miscellaneous");

            //Parse the lamp coordinates.
            var lampLocations = new List <ILocation>();
            var splitReg      = new Regex(@"\[(.*?)\]");
            var split         = splitReg.Matches(miscellaneousGroup.GetValue <string>("Lamp coordinates"));

            foreach (var match in split)
            {
                //Split into numbers only.
                var numbers = match.ToString().Replace("[", "").Replace("]", "").Split(' ');
                if (numbers.Length != 3)
                {
                    continue;
                }

                //Try-catch in case the user
                //entered an invalid character.
                try {
                    int x = int.Parse(numbers[0]);
                    int y = int.Parse(numbers[1]);
                    int z = int.Parse(numbers[2]);

                    lampLocations.Add(new Location(x, y, z));
                }
                catch { }
            }

            // Add listening tasks.
            RegisterTask(new Alerts(
                             ulong.Parse(Setting.At(0).Get <string>()),
                             Setting.At(1).Get <bool>(),
                             notificationsGroup.GetValue <bool>("Explosion notifications"), notificationsGroup.GetValue <bool>("Wither notifications"), notificationsGroup.GetValue <bool>("Creeper notifications"), notificationsGroup.GetValue <bool>("Player notifications"),
                             miscellaneousGroup.GetValue <string>("Friendly uuid(s)/name(s)"), lampLocations.ToArray(), (DiscordHelper.Mode)miscellaneousGroup.GetValue <int>("Mode"), notificationsGroup.GetValue <bool>("Detect falling tnt"), notificationsGroup.GetValue <bool>("Detect falling sand")
                             ));
        }
示例#20
0
        public override PluginResponse OnEnable(IBotSettings botSettings)
        {
            var notificationsGroup = (IParentSetting)Setting.Get("Notifications");
            var miscellaneousGroup = (IParentSetting)Setting.Get("Miscellaneous");

            if (!botSettings.loadEntities || !botSettings.loadPlayers)
            {
                return(new PluginResponse(false, "'Load entities & load players' must be enabled."));
            }
            if (!botSettings.loadWorld && !string.IsNullOrWhiteSpace(miscellaneousGroup.GetValue <string>("Lamp coordinates")))
            {
                return(new PluginResponse(false, "'Load worlds' must be enabled."));
            }

            try {
                if (string.IsNullOrWhiteSpace(Setting.At(0).Get <string>()))
                {
                    return(new PluginResponse(false, "Could not parse discord id."));
                }
                ulong.Parse(Setting.At(0).Get <string>());
            }
            catch (Exception ex) {
                return(new PluginResponse(false, "Could not parse discord id."));
            }

            // Do warnings.
            if (string.IsNullOrWhiteSpace(miscellaneousGroup.GetValue <string>("Lamp coordinates")) && (!botSettings.loadWorld || botSettings.staticWorlds))
            {
                DiscordHelper.Error("[RaidAlerts] 'Load worlds' should be enabled, 'Shared worlds' should be disabled.", 584);
            }
            if ((notificationsGroup.GetValue <bool>("Detect falling tnt") || notificationsGroup.GetValue <bool>("Detect falling sand")) && (!botSettings.loadEntities || !botSettings.loadMobs))
            {
                DiscordHelper.Error("[RaidAlerts] 'Load entities' & 'Load mobs' should be enabled.", 585);
            }

            return(new PluginResponse(true));
        }
示例#21
0
        private void SaveLoop()
        {
            while (!stopped)
            {
                if (toSaveQueue.IsEmpty)
                {
                    Thread.Sleep(50);
                    continue;
                }

                using (var stream = File.OpenWrite(Setting.At(0).Get <string>()))
                    while (!toSaveQueue.IsEmpty)
                    {
                        IPlayer player;
                        if (!toSaveQueue.TryDequeue(out player))
                        {
                            continue;
                        }

                        var bytes = Encoding.UTF8.GetBytes(Environment.NewLine + player.status.username + " - " + player.status.entity.location.ToLocation(0));
                        stream.Write(bytes, 0, bytes.Length);
                    }
            }
        }
示例#22
0
 public override void OnStart()
 {
     RegisterTask(new Follow(Setting.At(0).Get <string>()));
 }
示例#23
0
 public override void OnStart()
 {
     RegisterTask(new Chat(Setting.At(0).Get <bool>()));
 }
示例#24
0
 public override void OnStart()
 {
     RegisterTask(new Chat(Setting.At(0).Get <string>(), Setting.At(1).Get <string>(), Setting.At(2).Get <string>()));
 }
示例#25
0
 public override void OnStart()
 {
     Console.WriteLine("NameHistory Bot Loaded!");
     RegisterTask(new Tasks.ChatTask(Setting.At(0).Get <string>().Split(new char[] { ',' })));
 }