Пример #1
0
        private static bool Prefix(string q, CommandSender sender)
        {
            var player = sender.GetPlayer();
            var args   = q.Split(' ');

            if (q.StartsWith("@"))
            {
                return(true);
            }

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

            var allow = true;

            SynapseController.Server.Events.Server.InvokeRemoteAdminCommandEvent(sender, q, ref allow);
            if (!allow)
            {
                return(false);
            }

            if (SynapseController.CommandHandlers.RemoteAdminHandler.TryGetCommand(args[0], out var command))
            {
                //If sender has no permission and permission is not null or empty
                if (!sender.GetPlayer().HasPermission(command.Permission) && !string.IsNullOrWhiteSpace(command.Permission))
                {
                    player.SendRAConsoleMessage(Server.Get.Configs.SynapseTranslation.GetTranslation("noperm").Replace("%perm%", command.Permission), false);
                    return(false);
                }

                try
                {
                    var flag = command.Execute(new Command.CommandContext {
                        Arguments = args.Segment(1), Player = player, Platform = Command.Platform.RemoteAdmin
                    });

                    player.SendRAConsoleMessage(flag.Message, flag.State == CommandResultState.Ok);
                }
                catch (Exception e)
                {
                    Logger.Get.Error($"Synapse-Commands: Command Execution failed!!\n{e}\nStackTrace:\n{e.StackTrace}");
                }
                return(false);
            }

            return(true);
        }