From cb7e9bb572fff709e429738a3bb8e7670ad7ee21 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Tue, 25 Dec 2012 20:51:08 +0100 Subject: [PATCH] Whitelist now uses the clientID as a identifier as soon as the player has logged in one time --- TODO.md | 1 - classes/API/PlayerAPI.php | 2 +- classes/Player.class.php | 13 +++++++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/TODO.md b/TODO.md index 3b0fca31e..4ba5a6c97 100644 --- a/TODO.md +++ b/TODO.md @@ -14,7 +14,6 @@ __Check Milestones [here](https://github.com/shoghicp/PocketMine-MP/issues/miles ## Alpha (full Creative) - Random Chunk Updates - Water/lava spread -- Fix spawn position resetting - Correct block placement for beds - 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.) diff --git a/classes/API/PlayerAPI.php b/classes/API/PlayerAPI.php index d437422e2..00d530036 100644 --- a/classes/API/PlayerAPI.php +++ b/classes/API/PlayerAPI.php @@ -199,7 +199,7 @@ class PlayerAPI{ ), "health" => 20, "lastIP" => "", - "lastID" => "", + "lastID" => 0, ); $this->saveOffline($name, $data); }else{ diff --git a/classes/Player.class.php b/classes/Player.class.php index 7bc3264e0..4feea0a04 100644 --- a/classes/Player.class.php +++ b/classes/Player.class.php @@ -239,6 +239,15 @@ class Player{ break; case MC_LOGIN: $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); $c = $this->server->api->player->getByClientID($this->clientID); if($u !== false){ @@ -247,10 +256,6 @@ class Player{ if($c !== false){ $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->auth = true; $this->data["lastIP"] = $this->ip;