Exemplo n.º 1
0
        private PERM GetPermLevel(RocketPlayer p)
        {
            PERM perm = PERM.None;

            if (p.HasPermission(@"gearup.info"))
            {
                perm = PERM.Info;
            }

            if (p.HasPermission(@"gearup.self"))
            {
                perm = PERM.Self;
            }

            if (p.HasPermission(@"gearup.other"))
            {
                perm = PERM.Other;
            }

            if (p.HasPermission(@"gearup.admin"))
            {
                perm = PERM.Admin;
            }

            return(perm);
        }
Exemplo n.º 2
0
        public static async Task <bool> LazyCheckLocationPermissions()
        {
            try
            {
                PERM_STATUS locationStatus = await PERM.CheckStatusAsync <PERM.LocationAlways>();

                return(locationStatus == PERM_STATUS.Granted);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Exemplo n.º 3
0
        private static void Main(string[] args)
        {
            // Stopwatch for time it takes to solve
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();

            // Insert code for execution here
            Console.WriteLine(PERM.GetPermutations());

            // Stop timer and report time
            stopwatch.Stop();
            Console.WriteLine("Time elapsed: {0} ms", stopwatch.ElapsedMilliseconds);
        }
Exemplo n.º 4
0
        /**
         * VERIFICA LOS PERMISOS DE LA UBICACION
         */
        public static async Task <bool> CheckLocationPermissions()
        {
            try
            {
                PERM_STATUS locationStatus = await PERM.CheckStatusAsync <PERM.LocationAlways>();

                if (locationStatus != PERM_STATUS.Granted)
                {
                    locationStatus = await PERM.RequestAsync <PERM.LocationAlways>();

                    if (locationStatus != PERM_STATUS.Granted)
                    {
                        var title    = $"Permiso de ubicación";
                        var question = $"Para usar la aplicación el permiso de la ubicación es requerido";
                        var positive = "Configuración";
                        var negative = "Quizás después";

                        Task <bool> task = APP.Current?.MainPage?
                                           .DisplayAlert(title, question, positive, negative);
                        if (task == null)
                        {
                            return(false);
                        }

                        var result = await task;
                        if (result)
                        {
                            SERVICE.Get <IAppInfo>().OpenAppSettings();
                        }
                        return(false);
                    }
                }

                return(true);
            }
            catch (Exception e)
            {
                return(false);
            }
        }
Exemplo n.º 5
0
        public void Execute(RocketPlayer player, string[] cmd)
        {
            if (!Initialized)
            {
                Initialize();
            }

            if (player == null)
            {
                return;
            }

            if (!Config.AllowCmd)
            {
                Say(player, GearUp.TDict["command_disabled"]?.ToString(), Config.ErrorColor);
                Log("GU: Commands are disabled.");
                return;
            }

            PERM perms = GetPermLevel(player);

            try {
                if (perms <= PERM.None && string.Join("", cmd) != "-info")
                {
                    Say(player, GearUp.TDict["access_denied"]?.ToString(), Color.red);
                    return;
                }

                if (cmd.Length == 0 && perms >= PERM.Self)
                {
                    player.GetComponent <GearUpComp>()?.AskGearUp();
                    return;
                }

                if (cmd.Length >= 1)
                {
                    if (!cmd[0].StartsWith("-"))
                    {
                        RocketPlayer pFromCmd = RocketPlayer.FromName(cmd[0]);
                        Kit          kFromCmd = GetKitByName(cmd[0]);

                        // kit
                        if (kFromCmd != null && perms >= PERM.Self)
                        {
                            player.GetComponent <GearUpComp>()?.AskGearUp(null, kFromCmd);
                            return;
                        }

                        // player
                        if (pFromCmd != null && perms >= PERM.Other)
                        {
                            if (cmd.Length >= 2)
                            {
                                kFromCmd = GetKitByName(cmd[1]);
                                if (kFromCmd != null)
                                {
                                    pFromCmd.GetComponent <GearUpComp>()?.AskGearUp(player, kFromCmd);
                                    //Say(player, $"{GearUp.TDict["gear_gift_success"]?.Replace("%P", pFromCmd.CharacterName)}", Config.SuccessColor);
                                    return;
                                }
                                else
                                {
                                    Say(player, $"{GearUp.TDict["access_denied_gift"]?.ToString()}", Config.ErrorColor);
                                    return;
                                }
                            }
                            else
                            {
                                Say(player, $"{GearUp.TDict["error_user_nokit"]?.ToString()}", Config.ErrorColor);
                                return;
                            }
                        }

                        // neither; bad user, no biscuit! D:<
                        Say(player, $"No matching kits or players, kits: ", Config.ErrorColor);
                        ReportPermittedKits(player);
                        return;
                    }
                    else if (cmd[0].StartsWith("-"))
                    {
                        switch (cmd[0])
                        {
                        case "-on":
                            if ((int)perms < (int)PERM.Admin)
                            {
                                return;
                            }
                            GearUp.Instance.enabled = true;
                            Say(player, "GU: Enabled", Config.SuccessColor);
                            break;

                        case "-off":
                            if ((int)perms < (int)PERM.Admin)
                            {
                                return;
                            }
                            GearUp.Instance.enabled = false;
                            Say(player, "GU: Disabled", Config.SuccessColor);
                            break;

                        case "-kits":
                        case "-list":
                        case "-l":
                            ReportPermittedKits(player);
                            break;

                        case "-?":
                            if ((int)perms < (int)PERM.Info)
                            {
                                return;
                            }
                            ShowHelp(player);
                            break;

                        case "--":
                            if ((int)perms < (int)PERM.Info)
                            {
                                return;
                            }
                            Say(player, $"GU: Plugin {(GearUp.Instance.enabled == true ? "enabled" : "disabled")}.", Color.gray);
                            break;

                        case "-reset":
                            if ((int)perms < (int)PERM.Admin)
                            {
                                return;
                            }
                            if (cmd.Length >= 2)
                            {
                                if (!string.IsNullOrEmpty(cmd[1]))
                                {
                                    RocketPlayer p = RocketPlayer.FromName(cmd[1]);
                                    if (p == null)
                                    {
                                        Say(player, $"GU: Failed to find player name matching '{cmd[1]}'!", Config.ErrorColor);
                                    }
                                    else
                                    {
                                        p.GetComponent <GearUpComp>()?.ResetCooldown(player);
                                    }
                                }
                            }
                            else
                            {
                                player.GetComponent <GearUpComp>()?.ResetCooldown();
                            }
                            break;

                        case "-info":
                            Say(player, $"GearUp {GearUp.Version} by Mash - Auria.pw [{(GearUp.Instance.enabled == true ? "enabled" : "disabled")}]", Config.InfoColor);
                            break;

                        default:
                            Say(player, "GU: Unknown operand", Config.ErrorColor);
                            break;
                        }
                        return;
                    }
                }
            } catch (Exception ex) {
                GearUp.STOP(ex.Message);
            }
        }
Exemplo n.º 6
0
        /**
         * VERIFICA LOS PERMISOS DE LA VIDEOLLAMADA
         */
        public static async Task <bool> CheckVideoCallPermissions()
        {
            try
            {
                // -------------------------------------------------------------
                // SE VERIFICAN LOS PERMISOS DE LA CAMARA.
                // -------------------------------------------------------------
                PERM_STATUS CameraStatus = await PERM.CheckStatusAsync <PERM.Camera>();

                if (CameraStatus != PERM_STATUS.Granted)
                {
                    CameraStatus = await PERM.RequestAsync <PERM.Camera>();

                    if (CameraStatus != PERM_STATUS.Granted)
                    {
                        string title    = $"El Permiso de camara";
                        string question = $"Para usar la aplicación el permiso de la camara es requerido. Por favor acceda a configuración y habilite el permiso para la aplicación.";
                        string positive = "Configuración";
                        string negative = "Quizás después";

                        Task <bool> task = APP.Current?.MainPage?
                                           .DisplayAlert(title, question, positive, negative);
                        if (task == null)
                        {
                            return(false);
                        }

                        var result = await task;
                        if (result)
                        {
                            SERVICE.Get <IAppInfo>().OpenAppSettings();
                        }
                        return(false);
                    }
                }
                // -------------------------------------------------------------
                // SI YA SE OTORGO PERMISOS DE LA CAMARA
                // SE VERIFICAN LOS PERMISOS DEL MICROFONO.
                // -------------------------------------------------------------
                PERM_STATUS MicrophoneStatus = await PERM.CheckStatusAsync <PERM.Microphone>();

                if (MicrophoneStatus != PERM_STATUS.Granted)
                {
                    MicrophoneStatus = await PERM.RequestAsync <PERM.Microphone>();

                    if (MicrophoneStatus != PERM_STATUS.Granted)
                    {
                        string title    = $"Permiso de microfono";
                        string question = $"Para usar la aplicación el permiso del microfono es requerido. Por favor acceda a configuración y habilite el permiso para la aplicación.";
                        string positive = "Configuración";
                        string negative = "Quizás después";

                        Task <bool> task = APP.Current?.MainPage?
                                           .DisplayAlert(title, question, positive, negative);
                        if (task == null)
                        {
                            return(false);
                        }

                        var result = await task;
                        if (result)
                        {
                            SERVICE.Get <IAppInfo>().OpenAppSettings();
                        }

                        return(false);
                    }
                }
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }