Whitelist now uses the clientID as a identifier as soon as the player has logged in one time

This commit is contained in:
Shoghi Cervantes Pueyo 2012-12-25 20:51:08 +01:00
parent 504b37cfaa
commit cb7e9bb572
3 changed files with 10 additions and 6 deletions

View File

@ -14,7 +14,6 @@ __Check Milestones [here](https://github.com/shoghicp/PocketMine-MP/issues/miles
## Alpha (full Creative) ## Alpha (full Creative)
- Random Chunk Updates - Random Chunk Updates
- Water/lava spread - Water/lava spread
- Fix spawn position resetting
- Correct block placement for beds - Correct block placement for beds
- Correct chest/furnace placement - Correct chest/furnace placement
- Players can often hear "echos" of their own block interactions' SFX (torch placed, block destroyed, etc. most noticeable when moving around as you place.) - Players can often hear "echos" of their own block interactions' SFX (torch placed, block destroyed, etc. most noticeable when moving around as you place.)

View File

@ -199,7 +199,7 @@ class PlayerAPI{
), ),
"health" => 20, "health" => 20,
"lastIP" => "", "lastIP" => "",
"lastID" => "", "lastID" => 0,
); );
$this->saveOffline($name, $data); $this->saveOffline($name, $data);
}else{ }else{

View File

@ -239,6 +239,15 @@ class Player{
break; break;
case MC_LOGIN: case MC_LOGIN:
$this->username = str_replace("/", "", $data["username"]); $this->username = str_replace("/", "", $data["username"]);
if($this->username == ""){
$this->close("bad username", false);
break;
}
$o = $this->server->api->player->getOffline($this->username);
if($this->server->whitelist !== false and (!in_array($this->username, $this->server->whitelist) or ($o["lastID"] != 0 and $o["lastID"] != $this->clientID))){
$this->close("\"".$this->username."\" not being on white-list", false);
break;
}
$u = $this->server->api->player->get($this->username); $u = $this->server->api->player->get($this->username);
$c = $this->server->api->player->getByClientID($this->clientID); $c = $this->server->api->player->getByClientID($this->clientID);
if($u !== false){ if($u !== false){
@ -247,10 +256,6 @@ class Player{
if($c !== false){ if($c !== false){
$c->close("logged in from another location"); $c->close("logged in from another location");
} }
if($this->server->whitelist !== false and !in_array($this->username, $this->server->whitelist)){
$this->close("\"".$this->username."\" not being on white-list", false);
break;
}
$this->server->api->player->add($this->CID); $this->server->api->player->add($this->CID);
$this->auth = true; $this->auth = true;
$this->data["lastIP"] = $this->ip; $this->data["lastIP"] = $this->ip;