Пример #1
0
        public void cmd_PBC(CommandInfo info)
        {
            string[]      arg    = info.commandArgs;
            CommandSender sender = info.commandSender;

            if (!CustomInternalCommands.CheckPermissions(sender, arg[0], PlayerPermissions.Broadcasting))
            {
                return;
            }

            bool success = ushort.TryParse(arg[2], out ushort duration);

            if (arg.Count() < 4)
            {
                sender.RaReply(arg[0].ToUpper() + "#Command expects 3 or more arguments ([Players], [Seconds], [Message])", false, true, "");
                return;
            }
            else if (!success || duration < 1 || duration > 255)
            {
                sender.RaReply(arg[0].ToUpper() + "#Invalid duration given", false, true, "");
                return;
            }

            List <GameObject> playerList = CustomInternalCommands.GetPlayersFromString(arg[1]);

            string message = string.Join(" ", arg.Skip(3));

            foreach (GameObject player in playerList)
            {
                player.GetComponent <Broadcast>().TargetAddElement(player.GetComponent <NetworkConnection>(), message, duration, Broadcast.BroadcastFlags.Normal);
            }

            sender.RaReply(arg[0].ToUpper() + "Broadcast sent!", true, true, "");
        }
Пример #2
0
        public void cmd_oban(CommandInfo info)
        {
            CommandSender sender = info.commandSender;

            string[] arg = info.commandArgs;

            if (arg.Count() < 4)
            {
                sender.RaReply(arg[0].ToUpper() + "#Command expects 3 or more arguments ([UserID], [Minutes], [Reason])", false, true, "");
                return;
            }
            else if (!arg[1].Contains('@'))
            {
                sender.RaReply(arg[0].ToUpper() + "#Invalid UserID given", false, true, "");
                return;
            }

            char unit = arg[2].ToString().Where(Char.IsLetter).ToArray()[0];

            if (!int.TryParse(new string(arg[2].Where(Char.IsDigit).ToArray()), out int amount) || !CustomInternalCommands.validUnits.Contains(unit) || amount < 1)
            {
                sender.RaReply(arg[0].ToUpper() + "#Invalid duration", false, true, "");
                return;
            }

            TimeSpan duration = CustomInternalCommands.GetBanDuration(unit, amount);
            string   reason   = string.Join(" ", arg.Skip(3));

            if (duration.Minutes > 60 && !CustomInternalCommands.CheckPermissions(sender, arg[0], PlayerPermissions.KickingAndShortTermBanning))
            {
                return;
            }
            else if (duration.Minutes > 1440 && !CustomInternalCommands.CheckPermissions(sender, arg[0], PlayerPermissions.BanningUpToDay))
            {
                return;
            }

            BanHandler.IssueBan(new BanDetails
            {
                OriginalName = "Offline player",
                Id           = arg[1],
                Issuer       = sender.Nickname,
                IssuanceTime = DateTime.UtcNow.Ticks,
                Expires      = DateTime.UtcNow.Add(duration).Ticks,
                Reason       = reason.Replace(Environment.NewLine, "")
            }, BanHandler.BanType.UserId);

            sender.RaReply(arg[0].ToUpper() + $"#{arg[1]} was offline banned for {arg[2]}", true, true, "");
        }
Пример #3
0
        public static bool Prefix(ref string q, ref CommandSender sender)
        {
            try
            {
                QueryProcessor queryProcessor = sender is PlayerCommandSender playerCommandSender ? playerCommandSender.Processor : null;
                bool           allow          = true;

                if (q.ToLower().StartsWith("gban-kick"))
                {
                    if (queryProcessor == null || !queryProcessor._sender.SR.RaEverywhere)
                    {
                        sender.RaReply(
                            $"GBAN-KICK# Permission to run command denied by the server. If this is an unexpected error, contact EXILED developers.",
                            false, true, string.Empty);
                        Log.Error(
                            $"A user {sender.Nickname} attempted to run GBAN-KICK and was denied permission. If this is an unexpected error, contact EXILED developers.");
                        allow = false;
                    }
                }

                if (q.Contains("REQUEST_DATA PLAYER_LIST SILENT"))
                {
                    return(true);
                }

                Events.InvokeCommand(ref q, ref sender, ref allow);

                return(allow);
            }
            catch (Exception exception)
            {
                Log.Error($"RemoteAdminCommandEvent error: {exception}");
                return(true);
            }
        }
Пример #4
0
        /// <inheritdoc/>
        public bool Execute(ArraySegment <string> arguments, ICommandSender sender, out string response)
        {
            CommandSender cmdSender = (CommandSender)sender;

            if (!(Player.Get(cmdSender.SenderId) is Player player))
            {
                response = "You cannot use this command while still authenticating.";
                return(false);
            }

            void ErrorHandler() => cmdSender.RaReply("An error has occurred.", false, true, string.Empty);
            void SuccessHandler() => cmdSender.RaReply("Enjoy your credit tag!", true, true, string.Empty);

            bool cached = CreditTags.Instance.ShowCreditTag(player, ErrorHandler, SuccessHandler, true);

            response = cached ? "Your credit tag has been shown." : "Hold on...";
            return(true);
        }
Пример #5
0
        private static bool Prefix(ref string q, ref CommandSender sender)
        {
            QueryProcessor queryProcessor = sender is PlayerCommandSender playerCommandSender ? playerCommandSender.Processor : null;

            (string name, string[] arguments) = q.ExtractCommand();
            var ev = new SendingRemoteAdminCommandEventArgs(sender, string.IsNullOrEmpty(sender.SenderId) ? Server.Host : Player.Get(sender.SenderId) ?? Server.Host, name, arguments.ToList());

            IdleMode.PreauthStopwatch.Restart();
            IdleMode.SetIdleMode(false);

            if (q.ToLower().StartsWith("gban-kick"))
            {
                if (queryProcessor == null || !queryProcessor._sender.SR.RaEverywhere)
                {
                    sender.RaReply(
                        $"GBAN-KICK# Permission to run command denied by the server. If this is an unexpected error, contact EXILED developers.",
                        false,
                        true,
                        string.Empty);

                    Log.Error($"A user {sender.Nickname} attempted to run GBAN-KICK and was denied permission. If this is an unexpected error, contact EXILED developers.");

                    ev.IsAllowed = false;
                }
            }

            if (q.Contains("REQUEST_DATA PLAYER_LIST SILENT"))
            {
                return(true);
            }

            Handlers.Server.OnSendingRemoteAdminCommand(ev);

            if (!string.IsNullOrEmpty(ev.ReplyMessage))
            {
                sender.RaReply(ev.ReplyMessage, ev.Success, true, string.Empty);
            }

            return(ev.IsAllowed);
        }
Пример #6
0
    public static void RaMessage(this CommandSender sender, string message, bool success = true,
                                 RaCategory type = RaCategory.None)
    {
        var category = "";

        if (type != RaCategory.None)
        {
            category = type.ToString();
        }


        sender.RaReply($"{Assembly.GetCallingAssembly().GetName().Name}#" + message, success, true, category);
    }
Пример #7
0
        public static bool CheckPermissions(CommandSender sender, string queryZero, PlayerPermissions perm)
        {
            if (ServerStatic.IsDedicated && sender.FullPermissions)
            {
                return(true);
            }
            if (PermissionsHandler.IsPermitted(sender.Permissions, perm))
            {
                return(true);
            }

            sender.RaReply(queryZero.ToUpper() + "#You don't have permissions to execute this command.\nMissing permission: " + perm, false, true, "");
            return(false);
        }
Пример #8
0
        /// <summary>Gives a player a message in the RemoteAdmin</summary>
        /// <param name="sender">The User who you send the Message</param>
        /// <param name="message">The Message you want to send</param>
        /// <param name="success">True = green the command is right you have permission and execute it successfully</param>
        /// <param name="type">In Which Category should you see it too?</param>
        public static void RaMessage(this CommandSender sender, string message, bool success = true,
                                     RaCategory type = RaCategory.None)
        {
            var category = "";

            // ReSharper disable once SwitchStatementHandlesSomeKnownEnumValuesWithDefault
            switch (type)
            {
            case RaCategory.None:
                category = "";
                break;

            case RaCategory.PlayerInfo:
                category = "PlayerInfo";
                break;

            case RaCategory.ServerEvents:
                category = "ServerEvents";
                break;

            case RaCategory.DoorsManagement:
                category = "DoorsManagement";
                break;

            case RaCategory.AdminTools:
                category = "AdminTools";
                break;

            case RaCategory.ServerConfigs:
                category = "ServerConfigs";
                break;

            case RaCategory.PlayersManagement:
                category = "PlayersManagement";
                break;
            }


            sender.RaReply($"{Assembly.GetCallingAssembly().GetName().Name}#" + message, success, true, category);
        }
Пример #9
0
 //These are two commonly used extensions that will make your life considerably easier
 //When sending RaReply's, you need to identify the 'source' of the message with a string followed by '#' at the start of the message, otherwise the message will not be sent
 public static void RAMessage(this CommandSender sender, string message, bool success = true) =>
 sender.RaReply("Sample Plugin#" + message, success, true, string.Empty);
Пример #10
0
 public static void RAMessage(this CommandSender sender, string message, bool success = true) =>
 sender.RaReply("<color=green>Lights</color>#" + message, success, true, string.Empty);
Пример #11
0
 //These are two commonly used extensions that will make your life considerably easier
 //When sending RaReply's, you need to identify the 'source' of the message with a string followed by '#' at the start of the message, otherwise the message will not be sent
 public static void RaMessage(this CommandSender sender, string message, bool success = true) =>
 sender.RaReply("GhostSpectator#" + message, success, true, string.Empty);
Пример #12
0
 public static void RAMessage(this CommandSender sender, string message, bool success = true) =>
 sender.RaReply("CustAnnouncements#" + message, success, true, string.Empty);
Пример #13
0
 public void HandleCommand(string command, GameObject admin, CommandSender sender)
 {
     sender.RaReply(command.Split(' ')[0] + "#You don't have permissions to execute this command.\nMissing permission: ", false, true, "");
 }
Пример #14
0
 //These are two commonly used extensions that will make your life considerably easier
 //When sending RaReply's, you need to identify the 'source' of the message with a string followed by '#' at the start of the message, otherwise the message will not be sent
 public static void RAMessage(this CommandSender sender, string message, bool success = true) =>
 sender.RaReply("LaterJoinSimple" + message, success, true, string.Empty);
Пример #15
0
 public static void RAMessage(this CommandSender sender, string message, bool success = true) =>
 sender.RaReply("Discord Integration#" + message, success, true, string.Empty);
Пример #16
0
 // Adapted from https://github.com/galaxy119/SamplePlugin/blob/master/SamplePlugin/Extensions.cs
 /// <summary>
 /// Sends a message to the RA console of a <paramref name="sender"/>. <paramref name="pluginName"/> will be the name of your <see cref="Assembly"/>
 /// </summary>
 public static void RAMessage(this CommandSender sender, string message, bool success = true, string pluginName = null)
 {
     sender.RaReply((pluginName ?? Assembly.GetCallingAssembly().GetName().Name) + "#" + message, success, true, string.Empty);
 }
Пример #17
0
 //These are two commonly used extensions that will make your life considerably easier
 //When sending RaReply's, you need to identify the 'source' of the message with a string followed by '#' at the start of the message, otherwise the message will not be sent
 public static void RAMessage(this CommandSender sender, string message, bool success = true) =>
 sender.RaReply("ZombieLunging#" + message, success, true, string.Empty);