Example #1
0
        public void RemoveFromIpBanList(string ip)
        {
            bool    save = false;
            IIpBans i    = GetIpBan(ip);

            if (i != null)
            {
                _ipbans.Remove(i as IpBans);
                (from e in _bansDoc.Elements("Bans").Elements("IpBan")
                 where e.Element("IP").Value == ip
                 select e).Remove();
                save = true;
            }
            if (save)
            {
                _bansDoc.Save(BanFilePath);
            }
        }
Example #2
0
        internal void SendLoginSequence()
        {
            foreach (Client client in Server.GetAuthenticatedClients())
            {
                if (client.Username == Username)
                {
                    client.Stop();
                }
            }
            _player = new Player(Server, Server.AllocateEntity(), this);
            IBanSystem banSystem = _player.GetServer().GetBanSystem();

            if (ChraftConfig.WhiteList)
            {
                //todo has permission instead of can use command
                if (!_player.CanUseCommand("chraft.whitelist.exempt") && !banSystem.IsOnWhiteList(_player.Name))
                {
                    _player.GetClient().Kick(ChraftConfig.WhiteListMesasge);
                    return;
                }
            }

            IIpBans ipBan = banSystem.GetIpBan(_player.GetClient().IpAddress);
            IBans   ban   = _player.GetBan();

            if (ipBan != null)
            {
                if (DateTime.Compare(ipBan.Duration, new DateTime(1900, 01, 01, 00, 00, 00)) == 0 || ipBan.Duration >= DateTime.Now)
                {
                    _player.GetClient().Kick("Banned: " + ipBan.Reason);
                    return;
                }
                banSystem.RemoveFromIpBanList(_player.GetClient().IpAddress);
            }

            if (ban != null)
            {
                if (DateTime.Compare(ban.Duration, new DateTime(1900, 01, 01, 00, 00, 00)) == 0 || ban.Duration >= DateTime.Now)
                {
                    _player.GetClient().Kick("Banned: " + ban.Reason);
                    return;
                }
                banSystem.RemoveFromBanList(_player.Name);
            }



            _player.Permissions = _player.PermHandler.LoadClientPermission(this);
            Load();

            if (!_player.World.Running)
            {
                Stop();
                return;
            }

            SendLoginRequest();

            SendInitialTime(false);
            _player.UpdateChunks(4, CancellationToken.None, true, false);
            SendSpawnPosition(false);
            SendInitialPosition(false);
            SendInitialTime(false);
            SetGameMode();
            _player.InitializeInventory();
            _player.InitializeHealth();
            _player.SendUpdateExperience();
            _player.OnJoined();
            Server.AddEntity(_player, false);
            Server.AddAuthenticatedClient(this);
            SendMotd();
            StartKeepAliveTimer();
            _player.UpdateEntities();
            Server.SendEntityToNearbyPlayers(_player.World, _player);
            Server.FreeConnectionSlot();
        }