예제 #1
0
        override protected async Task Ban(string reason, EFClient targetClient, EFClient originClient, bool isEvade = false)
        {
            // ensure player gets banned if command not performed on them in game
            if (targetClient.ClientNumber < 0)
            {
                EFClient ingameClient = null;

                ingameClient = Manager.GetServers()
                               .Select(s => s.GetClientsAsList())
                               .FirstOrDefault(l => l.FirstOrDefault(c => c.ClientId == targetClient?.ClientId) != null)
                               ?.First(c => c.ClientId == targetClient.ClientId);

                if (ingameClient != null)
                {
                    await Ban(reason, ingameClient, originClient, isEvade);

                    return;
                }
            }

            else
            {
#if !DEBUG
                string formattedString = String.Format(RconParser.Configuration.CommandPrefixes.Kick, targetClient.ClientNumber, $"{loc["SERVER_BAN_TEXT"]} - ^5{reason} ^7{loc["SERVER_BAN_APPEAL"].FormatExt(Website)}^7");
                await targetClient.CurrentServer.ExecuteCommandAsync(formattedString);
#else
                await targetClient.CurrentServer.OnClientDisconnected(targetClient);
#endif
            }

            Penalty newPenalty = new Penalty()
            {
                Type             = Penalty.PenaltyType.Ban,
                Expires          = null,
                Offender         = targetClient,
                Offense          = reason,
                Punisher         = originClient,
                Link             = targetClient.AliasLink,
                AutomatedOffense = originClient.AdministeredPenalties?.FirstOrDefault()?.AutomatedOffense,
                IsEvadedOffense  = isEvade
            };

            targetClient.SetLevel(Permission.Banned, originClient);
            await Manager.GetPenaltyService().Create(newPenalty);
        }
예제 #2
0
        override public async Task Unban(string reason, EFClient Target, EFClient Origin)
        {
            var unbanPenalty = new Penalty()
            {
                Type     = Penalty.PenaltyType.Unban,
                Expires  = null,
                Offender = Target,
                Offense  = reason,
                Punisher = Origin,
                When     = DateTime.UtcNow,
                Active   = true,
                Link     = Target.AliasLink
            };

            await Manager.GetPenaltyService().RemoveActivePenalties(Target.AliasLink.AliasLinkId, Origin);

            await Manager.GetPenaltyService().Create(unbanPenalty);

            Target.SetLevel(Permission.User, Origin);
        }