Added login timeout for players that do not complete the login process in time

This commit is contained in:
Shoghi Cervantes 2015-05-14 14:52:39 +02:00
parent b1edfd7631
commit e61db8ad06
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89
2 changed files with 11 additions and 8 deletions

View File

@ -1495,7 +1495,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
switch($packet->pid()){
case ProtocolInfo::LOGIN_PACKET:
if($this->loggedIn === true){
if($this->loggedIn){
break;
}

View File

@ -2207,15 +2207,18 @@ class Server{
$this->identifiers[spl_object_hash($player)] = $identifier;
}
private function checkTickUpdates($currentTick){
private function checkTickUpdates($currentTick, $tickTime){
foreach($this->players as $p){
if(!$p->loggedIn and ($tickTime - $p->creationTime) >= 10){
$p->close("", "Login timeout");
}elseif($this->alwaysTickPlayers){
$p->onUpdate($currentTick);
}
}
//Do level ticks
foreach($this->getLevels() as $level){
if($level->getTickRate() > $this->baseTickRate and --$level->tickRateCounter > 0){
if($this->alwaysTickPlayers){
foreach($level->getPlayers() as $p){
$p->onUpdate($currentTick);
}
}
continue;
}
try{
@ -2405,7 +2408,7 @@ class Server{
$this->scheduler->mainThreadHeartbeat($this->tickCounter);
Timings::$schedulerTimer->stopTiming();
$this->checkTickUpdates($this->tickCounter);
$this->checkTickUpdates($this->tickCounter, $tickTime);
if(($this->tickCounter & 0b1111) === 0){
$this->titleTick();