Correct MC_LOGIN_STATUS usage

This commit is contained in:
Shoghi Cervantes Pueyo 2013-04-18 16:16:54 +02:00
parent 8f724ffc46
commit 5848d283da

View File

@ -200,9 +200,6 @@ class Player{
} }
$reason = $reason == "" ? "server stop":$reason; $reason = $reason == "" ? "server stop":$reason;
$this->eventHandler(new Container("You have been kicked. Reason: ".$reason), "server.chat"); $this->eventHandler(new Container("You have been kicked. Reason: ".$reason), "server.chat");
$this->directDataPacket(MC_LOGIN_STATUS, array(
"status" => 1,
));
$this->directDataPacket(MC_DISCONNECT); $this->directDataPacket(MC_DISCONNECT);
$this->sendBuffer(); $this->sendBuffer();
$this->buffer = null; $this->buffer = null;
@ -692,29 +689,37 @@ class Player{
if(count($this->server->clients) >= $this->server->maxClients){ if(count($this->server->clients) >= $this->server->maxClients){
$this->close("server is full!", false); $this->close("server is full!", false);
return; return;
} }
if($data["protocol1"] !== CURRENT_PROTOCOL){ if($data["protocol1"] !== CURRENT_PROTOCOL){
$this->close("protocol", false); if($data["protocol1"] < CURRENT_PROTOCOL){
$this->directDataPacket(MC_LOGIN_STATUS, array(
"status" => 1,
));
}else{
$this->directDataPacket(MC_LOGIN_STATUS, array(
"status" => 2,
));
}
$this->close("Incorrect protocol", false);
break; break;
} }
if(preg_match('#^[a-zA-Z0-9_]{2,16}$#', $data["username"])){ if(preg_match('#^[a-zA-Z0-9_]{2,16}$#', $data["username"])){
$this->username = $data["username"]; $this->username = $data["username"];
$this->iusername = strtolower($this->username); $this->iusername = strtolower($this->username);
}else{ }else{
$this->close("bad username", false); $this->close("Bad username", false);
break; break;
} }
if($this->server->api->handle("player.connect", $this) === false){ if($this->server->api->handle("player.connect", $this) === false){
$this->close("join cancelled", false); $this->close("Unknown reason", false);
return; return;
} }
if($this->server->whitelist === true and !$this->server->api->ban->inWhitelist($this->iusername)){ if($this->server->whitelist === true and !$this->server->api->ban->inWhitelist($this->iusername)){
$this->close("\x1b[33m".$this->username."\x1b[0m not being on white-list", false); $this->close("Server is white-listed", false);
return; return;
}elseif($this->server->api->ban->isBanned($this->iusername) or $this->server->api->ban->isIPBanned($this->ip)){ }elseif($this->server->api->ban->isBanned($this->iusername) or $this->server->api->ban->isIPBanned($this->ip)){
$this->close("\x1b[33m".$this->username."\x1b[0m is banned!", false); $this->close("You are banned!", false);
return; return;
} }
$this->loggedIn = true; $this->loggedIn = true;