예제 #1
0
        /// <summary>
        /// Bans the user for the specified reason and duration
        /// </summary>
        /// <param name="id"></param>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string id, string reason, TimeSpan duration = default(TimeSpan))
        {
            // Check if already banned
            if (IsBanned(id))
            {
                return;
            }

            // Ban and kick user
            Netplay.AddBan(int.Parse(id));
            //if (IsConnected) Kick(reason); // TODO: Implement if possible
        }
예제 #2
0
        /// <summary>
        /// Bans the user for the specified reason and duration
        /// </summary>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string reason, TimeSpan duration = default(TimeSpan))
        {
            // Check already banned
            if (IsBanned)
            {
                return;
            }

            // Set to banned
            Netplay.AddBan(player.whoAmI);
            NetMessage.SendData(2, player.whoAmI, -1, reason);
        }
예제 #3
0
        /// <summary>
        /// Bans the user for the specified reason and duration
        /// </summary>
        /// <param name="reason"></param>
        /// <param name="duration"></param>
        public void Ban(string reason, TimeSpan duration = default(TimeSpan))
        {
            // Check if already banned
            if (IsBanned)
            {
                return;
            }

            // Ban and kick user
            Netplay.AddBan(player.whoAmI);
            if (IsConnected)
            {
                Kick(reason);
            }
        }
예제 #4
0
 private static void ProcessRequestBanPlayer(ref BinaryReader reader, int playerNumber)
 {
     if (Network.Players[playerNumber].Group.HasPermission("Ban"))
     {
         string playertoban = reader.ReadString();
         ModUtils.DebugText("Server Ban request received: " + playertoban);
         for (int k = 0; k < 255; k++)
         {
             if (Main.player[k].active && Main.player[k].name.ToLower() == playertoban)
             {
                 Netplay.AddBan(k);
                 NetMessage.SendData(2, k, -1, NetworkText.FromKey("CLI.BanMessage", new object[0]), 0, 0f, 0f, 0f, 0, 0, 0);
             }
         }
     }
 }
예제 #5
0
 public override void HandleCommand(BinaryReader reader, int playerNumber)
 {
     // 服务器端
     if (Main.netMode == 2)
     {
         int    target = reader.ReadInt32();
         string banner = Main.player[playerNumber].name;
         string reason = reader.ReadString();
         var    player = ServerSideCharacter2.PlayerCollection.Get(target);
         player.Ban(banner, reason);
         string str = $"玩家 {player.Name} 被管理员 {banner} 安排了, 原因是:{reason}";
         Netplay.AddBan(player.PrototypePlayer.whoAmI);
         ServerPlayer.SendInfoMessageToAll(str);
         CommandBoardcast.ConsoleMessage(str);
     }
 }
예제 #6
0
 public override void execute(params string[] parameters)
 {
     if (parameters.Length == 0 || string.Concat(parameters).Trim() == "")
     {
         Console.WriteLine("Usage: ban <player>");
     }
     else
     {
         string target = string.Join(" ", parameters).ToLower();
         for (int k = 0; k < 255; k++)
         {
             if (Main.player[k].active && Main.player[k].name.ToLower() == target)
             {
                 Netplay.AddBan(k);
                 NetMessage.SendData(2, k, -1, "Banned from server.", 0, 0f, 0f, 0f, 0);
             }
         }
     }
 }