예제 #1
0
        internal static void OnVerified(VerifiedEventArgs ev)
        {
            Player dPlayer = ev.Player.GetPlayer() ?? new Collections.Player(
                ev.Player.RawUserId,
                ev.Player.AuthenticationType.ToString().ToLower(),
                ev.Player.Nickname
                );

            PlayerData.Add(ev.Player, dPlayer);

            if (dPlayer.Name != ev.Player.Nickname)
            {
                dPlayer.Name = ev.Player.Nickname;
                dPlayer.Save();
            }

            if (!dPlayer.IsMuted() && MuteHandler.QueryPersistentMute($"{dPlayer.Id}@{dPlayer.Authentication}"))
            {
                MuteHandler.RevokePersistentMute($"{dPlayer.Id}@{dPlayer.Authentication}");
            }
            if (!WatchListCollection.Exists(p => p.Target == ev.Player.GetPlayer()))
            {
                return;
            }
            foreach (Exiled.API.Features.Player staffer in Exiled.API.Features.Player.List.Where(ply => ply.RemoteAdminAccess))
            {
                staffer.Broadcast(Plugin.Singleton.Config.Translation.WatchlistStaffersBroadcastJoin.Duration, Plugin.Singleton.Config.Translation.WatchlistStaffersBroadcastJoin.Content.Replace("{player}", $"{ev.Player.Nickname} ({ev.Player.UserId})").Replace("{reason}", WatchListCollection.Find(ply => ply.Target == ev.Player.GetPlayer()).Last().Reason), global::Broadcast.BroadcastFlags.Normal, true);
            }
            if (dPlayer.IsBanned())
            {
                ev.Player?.Disconnect(Plugin.Singleton.Config.Translation.BanTranslation.PlayerBanMessage.Replace("{reason}", BanCollection.Find(b => b.Target == dPlayer).Last().Reason));
            }
        }
예제 #2
0
        private static bool Prefix(CharacterClassManager __instance, bool value)
        {
            try
            {
                ChangingMuteStatusEventArgs ev = new ChangingMuteStatusEventArgs(API.Features.Player.Get(__instance._hub), value, true);

                Player.OnChangingMuteStatus(ev);

                if (!ev.IsAllowed)
                {
                    if (value == true)
                    {
                        MuteHandler.RevokePersistentMute(__instance.UserId);
                    }
                    else
                    {
                        MuteHandler.IssuePersistentMute(__instance.UserId);
                    }

                    return(false);
                }

                return(true);
            }
            catch (Exception e)
            {
                Exiled.API.Features.Log.Error($"{typeof(ChangingMuteStatus).FullName}.{nameof(Prefix)}:\n{e}");
                return(true);
            }
        }
        /// <summary>
        /// Clear a punish to the specified <see cref="Player"/>.
        /// </summary>
        /// <param name="player">The <see cref="Collections.Player"/> player.</param>
        /// <param name="type"> the <see cref="Enums.PunishType"/>.</param>
        /// <param name="id"> the punish id.</param>
        /// <param name="server"> the server port.</param>
        public static void ClearPunishment(Collections.Player player, PunishType?type, int id, int server)
        {
            switch (type)
            {
            case PunishType.Ban:
                Ban ban = BanCollection.FindOne(b => b.Target == player && b.BanId == id && b.Server == server);

                JsonManager.PunishToCache(type, JsonConvert.SerializeObject(ban), player, ActionType.Remove);

                if (player.IsBanned())
                {
                    BanHandler.RemoveBan($"{player.Id}@{player.Authentication}", BanHandler.BanType.IP);
                }

                BanCollection.Delete(ban.Id);
                break;

            case PunishType.Kick:
                Kick kick = KickCollection.FindOne(k => k.Target == player && k.KickId == id && k.Server == server);

                JsonManager.PunishToCache(type, JsonConvert.SerializeObject(kick), player, ActionType.Remove);

                KickCollection.Delete(kick.Id);
                break;

            case PunishType.Mute:
                Mute mute = MuteCollection.FindOne(m => m.Target == player && m.MuteId == id && m.Server == server);

                JsonManager.PunishToCache(type, JsonConvert.SerializeObject(mute), player, ActionType.Remove);

                if (player.IsMuted())
                {
                    MuteHandler.RevokePersistentMute($"{player.Id}@{player.Authentication}");
                }

                MuteCollection.Delete(mute.Id);
                break;

            case PunishType.Warn:
                Warn warn = WarnCollection.FindOne(w => w.Target == player && w.WarnId == id && w.Server == server);

                JsonManager.PunishToCache(type, JsonConvert.SerializeObject(warn), player, ActionType.Remove);

                WarnCollection.Delete(warn.Id);
                break;

            case PunishType.SoftWarn:
                SoftWarn softWarn = SoftWarnCollection.FindOne(sw => sw.Target == player && sw.SoftWarnId == id && sw.Server == server);

                JsonManager.PunishToCache(type, JsonConvert.SerializeObject(softWarn), player, ActionType.Remove);

                SoftWarnCollection.Delete(softWarn.Id);
                break;

            case PunishType.SoftBan:
                SoftBan softBan = SoftBanCollection.FindOne(sb => sb.Target == player && sb.SoftBanId == id && sb.Server == server);

                JsonManager.PunishToCache(type, JsonConvert.SerializeObject(softBan), player, ActionType.Remove);

                SoftBanCollection.Delete(softBan.Id);
                break;

            case PunishType.WatchList:
                WatchList watchList = WatchListCollection.FindOne(wl => wl.Target == player && wl.WatchListId == id && wl.Server == server);

                JsonManager.PunishToCache(type, JsonConvert.SerializeObject(watchList), player, ActionType.Remove);

                WatchListCollection.Delete(watchList.Id);
                break;
            }
        }