Case-insensitive playernames, removed Client ID kick

This commit is contained in:
Shoghi Cervantes Pueyo 2013-03-07 17:43:44 +01:00
parent a7d8e22e7e
commit 8253d63d9b
2 changed files with 27 additions and 24 deletions

View File

@ -31,24 +31,25 @@ class Player{
private $queue = array(); private $queue = array();
private $buffer = array(); private $buffer = array();
private $evid = array(); private $evid = array();
var $timeout; public $timeout;
var $connected = true; public $connected = true;
var $clientID; public $clientID;
var $ip; public $ip;
var $port; public $port;
var $counter = array(0, 0, 0); public $counter = array(0, 0, 0);
var $username; public $username;
var $eid = false; public $iusername;
var $data = array(); public $eid = false;
var $entity = false; public $data = array();
var $auth = false; public $entity = false;
var $CID; public $auth = false;
var $MTU; public $CID;
var $spawned = false; public $MTU;
var $inventory; public $spawned = false;
public $inventory;
public $equipment; public $equipment;
public $armor; public $armor;
var $loggedIn = false; public $loggedIn = false;
public $gamemode; public $gamemode;
public $lastBreak; public $lastBreak;
public $windowCnt = 0; public $windowCnt = 0;
@ -529,25 +530,23 @@ class Player{
} }
$this->loggedIn = true; $this->loggedIn = true;
$this->username = str_replace(array("\x00", "/", " ", "\r", "\n", '"', "'"), array("", "-", "_", "", "", "", ""), $data["username"]); $this->username = str_replace(array("\x00", "/", " ", "\r", "\n", '"', "'"), array("", "-", "_", "", "", "", ""), $data["username"]);
$this->iusername = strtolower($this->username);
if($this->username == ""){ if($this->username == ""){
$this->close("bad username", false); $this->close("bad username", false);
break; break;
} }
$o = $this->server->api->player->getOffline($this->username); $o = $this->server->api->player->getOffline($this->username);
if($this->server->whitelist === true and !$this->server->api->ban->inWhitelist($this->username)){ 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("\"\x1b[33m".$this->username."\x1b[0m\" not being on white-list", false);
break; break;
}elseif($this->server->api->ban->isBanned($this->username) 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("\"\x1b[33m".$this->username."\x1b[0m\" is banned!", false);
} }
$u = $this->server->api->player->get($this->username); $u = $this->server->api->player->get($this->iusername);
$c = $this->server->api->player->getByClientID($this->clientID);
if($u !== false){ if($u !== false){
$u->close("logged in from another location"); $u->close("logged in from another location");
} }
if($c !== false){
$c->close("logged in from another location");
}
if($this->server->api->dhandle("player.join", $this) === false){ if($this->server->api->dhandle("player.join", $this) === false){
$this->close(); $this->close();
@ -618,6 +617,10 @@ class Player{
if($this->MTU <= 548){ if($this->MTU <= 548){
$this->eventHandler("Your connection is bad, you may experience lag and slow map loading.", "server.chat"); $this->eventHandler("Your connection is bad, you may experience lag and slow map loading.", "server.chat");
} }
if($this->iusername === "steve" or $this->iusername === "stevie"){
$this->eventHandler("You're using the default username. Please change it on the Minecraft PE settings.", "server.chat");
}
$this->sendInventory(); $this->sendInventory();
$this->entity->setPosition($this->entity->x, $this->entity->y, $this->entity->z, 0, 0); $this->entity->setPosition($this->entity->x, $this->entity->y, $this->entity->z, 0, 0);
/* /*

View File

@ -115,7 +115,7 @@ class PocketMinecraftServer{
//$this->query("PRAGMA journal_mode = OFF;"); //$this->query("PRAGMA journal_mode = OFF;");
//$this->query("PRAGMA encoding = \"UTF-8\";"); //$this->query("PRAGMA encoding = \"UTF-8\";");
//$this->query("PRAGMA secure_delete = OFF;"); //$this->query("PRAGMA secure_delete = OFF;");
$this->query("CREATE TABLE players (clientID INTEGER PRIMARY KEY, EID NUMERIC, ip TEXT, port NUMERIC, name TEXT UNIQUE);"); $this->query("CREATE TABLE players (clientID INTEGER PRIMARY KEY, EID NUMERIC, ip TEXT, port NUMERIC, name TEXT UNIQUE COLLATE NOCASE);");
$this->query("CREATE TABLE entities (EID INTEGER PRIMARY KEY, type NUMERIC, class NUMERIC, name TEXT, x NUMERIC, y NUMERIC, z NUMERIC, yaw NUMERIC, pitch NUMERIC, health NUMERIC);"); $this->query("CREATE TABLE entities (EID INTEGER PRIMARY KEY, type NUMERIC, class NUMERIC, name TEXT, x NUMERIC, y NUMERIC, z NUMERIC, yaw NUMERIC, pitch NUMERIC, health NUMERIC);");
$this->query("CREATE TABLE tileentities (ID INTEGER PRIMARY KEY, class TEXT, x NUMERIC, y NUMERIC, z NUMERIC, spawnable NUMERIC);"); $this->query("CREATE TABLE tileentities (ID INTEGER PRIMARY KEY, class TEXT, x NUMERIC, y NUMERIC, z NUMERIC, spawnable NUMERIC);");
$this->query("CREATE TABLE actions (ID INTEGER PRIMARY KEY, interval NUMERIC, last NUMERIC, code TEXT, repeat NUMERIC);"); $this->query("CREATE TABLE actions (ID INTEGER PRIMARY KEY, interval NUMERIC, last NUMERIC, code TEXT, repeat NUMERIC);");