Exemple #1
0
        public void Invoke(ShPlayer player, string target = null)
        {
            if (target != null && !player.svPlayer.HasPermission($"{Core.Instance.Info.GroupNamespace}.{nameof(WarnList)}.viewotherplayers"))
            {
                player.TS("warns_noPermission_viewOtherPlayers");
                return;
            }

            if (target == null)
            {
                SendWarnList(player, player.username, player.GetWarns());
                return;
            }

            if (EntityCollections.TryGetPlayerByNameOrID(target, out var shTarget))
            {
                SendWarnList(player, shTarget.username, shTarget.GetWarns());
                return;
            }

            if (Core.Instance.SvManager.TryGetUserData(target, out var user))
            {
                SendWarnList(player, user.ID, user.GetWarns());
                return;
            }

            player.TS("user_not_found", target.CleanerMessage());
        }
Exemple #2
0
        public void Invoke(ShPlayer player, ShPlayer target = null)
        {
            if (target != null && !player.svPlayer.HasPermission($"{Core.Instance.Info.GroupNamespace}.{nameof(WarnList)}.viewotherplayers"))
            {
                player.TS("warns_noPermission_viewOtherPlayers");
                return;
            }
            target = target ?? player;
            var           warns         = target.GetWarns().Select(warn => warn.ToString(player)).ToArray();
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.AppendLine(player.T("warns_for", target.username.CleanerMessage()));
            if (warns.Length == 0)
            {
                stringBuilder.AppendLine(player.T("none"));
            }
            else
            {
                stringBuilder.AppendLine(player.T("warns_count", warns.Length.ToString()));
                stringBuilder.AppendLine();
                for (int i = 0; i < warns.Length; i++)
                {
                    stringBuilder.AppendLine($"{i + 1} - {warns[i]}");
                }
            }
            player.svPlayer.Send(SvSendType.Self, Channel.Reliable, ClPacket.ServerInfo, stringBuilder.ToString());
        }
Exemple #3
0
        public void Invoke(ShPlayer player, ShPlayer target, int warnId)
        {
            if (warnId < 1)
            {
                player.TS("warn_remove_error_null_or_negative", warnId.ToString());
                return;
            }
            var warns = target.GetWarns();

            if (warns.Count < warnId)
            {
                player.TS("warn_remove_error_notExistant", warnId.ToString());
                return;
            }
            player.TS("player_warn_removed", warns[warnId - 1].ToString(player));
            target.RemoveWarn(warnId - 1);
        }