Kick() public method

Kick (asynchronous). Immediately blocks all client input, but waits until client thread has sent the kick packet.
public Kick ( [ message, LeaveReason leaveReason ) : void
message [
leaveReason LeaveReason
return void
Esempio n. 1
0
        public Map AcceptPlayer([NotNull] Player player, bool announce)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }

            lock ( SyncRoot ) {
                if (IsFull)
                {
                    if (player.Info.Rank.ReservedSlot)
                    {
                        Player idlestPlayer = Players.Where(p => p.Info.Rank.IdleKickTimer != 0)
                                              .OrderBy(p => p.LastActiveTime)
                                              .FirstOrDefault();
                        if (idlestPlayer != null)
                        {
                            idlestPlayer.Kick(Player.Console, "Auto-kicked to make room (idle).",
                                              LeaveReason.IdleKick, false, false, false);
                            Server.Message("Player {0}&S was auto-kicked to make room for {1}",
                                           idlestPlayer.ClassyName, player.ClassyName);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }

                if (playerIndex.ContainsKey(player.Name.ToLower()))
                {
                    Logger.Log(LogType.Error,
                               "This world already contains the player by name ({0}). " +
                               "Some sort of state corruption must have occured.",
                               player.Name);
                    playerIndex.Remove(player.Name.ToLower());
                }

                playerIndex.Add(player.Name.ToLower(), player);

                // load the map, if it's not yet loaded
                IsPendingMapUnload = false;
                Map = LoadMap();

                if (ConfigKey.BackupOnJoin.Enabled() && (Map.HasChangedSinceBackup || !ConfigKey.BackupOnlyWhenChanged.Enabled()))
                {
                    string backupFileName = String.Format(JoinBackupFormat,
                                                          Name, DateTime.Now, player.Name);   // localized
                    Map.SaveBackup(MapFileName,
                                   Path.Combine(Paths.BackupPath, backupFileName));
                }

                UpdatePlayerList();

                if (announce && ConfigKey.ShowJoinedWorldMessages.Enabled())
                {
                    Server.Players.CanSee(player)
                    .Message("&SPlayer {0}&S joined {1}",
                             player.ClassyName, ClassyName);
                }

                Logger.Log(LogType.UserActivity,
                           "Player {0} joined world {1}.",
                           player.Name, Name);

                if (IsLocked)
                {
                    player.Message("&WThis map is currently locked (read-only).");
                }

                if (player.Info.IsHidden)
                {
                    player.Message("&8Reminder: You are still hidden.");
                }

                return(Map);
            }
        }
Esempio n. 2
0
 static void RageHandler(Player player, Command cmd)
 {
     string reason = cmd.NextAll();
     if (reason.Length < 1)
     {
         Server.Players.Message("{0} &4Ragequit from the server", player.ClassyName);
         player.Kick(Player.Console, "&4Ragequit", LeaveReason.RageQuit, false, false, false);
         IRC.SendAction(player.ClassyName + " &4Ragequit from the server");
         return;
     }
     else
     {
         Server.Players.Message("{0} &4Ragequit from the server: &C{1}",
                         player.ClassyName, reason);
         IRC.SendAction(player.ClassyName + " &WRagequit from the server: " + reason);
         player.Kick(Player.Console, reason, LeaveReason.RageQuit, false, false, false);
     }
 }
Esempio n. 3
0
        internal Map AcceptPlayer([NotNull] Player player, bool announce)
        {
            if (player == null)
            {
                throw new ArgumentNullException("player");
            }

            lock (SyncRoot) {
                if (IsFull)
                {
                    if (player.Info.Rank.HasReservedSlot)
                    {
                        Player idlestPlayer = Players.Where(p => p.Info.Rank.IdleKickTimer != 0)
                                              .OrderBy(p => p.LastActiveTime)
                                              .FirstOrDefault();
                        if (idlestPlayer != null)
                        {
                            idlestPlayer.Kick(Player.Console,
                                              "Auto-kicked to make room (idle).",
                                              LeaveReason.IdleKick,
                                              KickOptions.None);

                            Server.Players
                            .CanSee(player)
                            .Message("&SPlayer {0}&S was auto-kicked to make room for {1}",
                                     idlestPlayer.ClassyName,
                                     player.ClassyName);
                            Server.Players
                            .CantSee(player)
                            .Message("{0}&S was kicked for being idle for {1} min",
                                     player.ClassyName,
                                     player.Info.Rank.IdleKickTimer);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }

                if (playerIndex.ContainsKey(player.Name.ToLower()))
                {
                    Logger.Log(LogType.Error,
                               "This world already contains the player by name ({0}). " +
                               "Some sort of state corruption must have occurred.",
                               player.Name);
                    playerIndex.Remove(player.Name.ToLower());
                }

                playerIndex.Add(player.Name.ToLower(), player);

                // load the map, if it's not yet loaded
                IsPendingMapUnload = false;
                Map = LoadMap();

                UpdatePlayerList();

                if (announce && ConfigKey.ShowJoinedWorldMessages.Enabled())
                {
                    Server.Players.CanSee(player)
                    .Message("&SPlayer {0}&S joined {1}",
                             player.ClassyName,
                             ClassyName);
                }

                Logger.Log(LogType.UserActivity,
                           "Player {0} joined world {1}.",
                           player.Name,
                           Name);

                if (IsLocked)
                {
                    player.Message("&WThis map is currently locked (read-only).");
                }

                if (player.Info.IsHidden)
                {
                    player.Message("&8Reminder: You are still hidden.");
                }

                return(Map);
            }
        }
Esempio n. 4
0
        static void RageHandler(Player player, Command cmd)
        {
            string reason = cmd.NextAll();

            if (reason.Length < 1)
            {
                Server.Players.Message("{0} &4Ragequit from the server", player.ClassyName);
                player.Kick(Player.Console, "Ragequit", LeaveReason.RageQuit, false, false, false);
                IRC.IRCAnnounceCustom(String.Format("{0} &4Ragequit from the server", player.ClassyName));
                return;
            }

            else
            {
                Server.Players.Message("{0} &4Ragequit from the server: &C{1}",
                                player.ClassyName, reason);
                IRC.IRCAnnounceCustom(String.Format("{0} &4Ragequit from the server: &C{1}",
                                player.ClassyName, reason));
                player.Kick(Player.Console, reason, LeaveReason.RageQuit, false, false, false);
            }
        }
Esempio n. 5
0
 static void QuitHandler(Player player, CommandReader cmd) {
     string Msg = "/Quit" + (cmd.HasNext ? " " + cmd.NextAll() : "");
     player.usedquit = true;
     player.quitmessage = (Msg.Length > 70 ? Msg.Remove(70) : Msg);
     player.Kick(Msg, LeaveReason.ClientQuit);
     Logger.Log(LogType.UserActivity,
                 "{0} left the server. Reason: {1}", player.Name, player.quitmessage);
 }