Map saving, breaking blocks. Huge rewrite

This commit is contained in:
Shoghi Cervantes Pueyo
2012-12-16 23:33:18 +01:00
parent 72c4cc7a30
commit 3a2010696f
15 changed files with 423 additions and 484 deletions

View File

@ -73,7 +73,7 @@ class PlayerAPI{
case "list":
console("[INFO] Player list:");
foreach($this->server->clients as $c){
console("[INFO] ".$c->username." (".$c->ip.":".$c->port."), ClientID ".$c->clientID.", (".round($c->username->entity->position["x"], 2).", ".round($c->username->entity->position["y"], 2).", ".round($c->username->entity->position["z"], 2).")");
console("[INFO] ".$c->username." (".$c->ip.":".$c->port."), ClientID ".$c->clientID.", (".round($c->username->entity->x, 2).", ".round($c->username->entity->y, 2).", ".round($c->username->entity->z, 2).")");
}
break;
}
@ -82,7 +82,7 @@ class PlayerAPI{
public function teleport($name, $target){
$target = $this->get($target);
if($target !== false){
$this->tppos($name, $target->entity->position["x"], $target->entity->position["y"], $target->entity->position["z"]);
$this->tppos($name, $target->entity->x, $target->entity->y, $target->entity->z);
}
}
@ -102,6 +102,10 @@ class PlayerAPI{
return false;
}
public function getAll(){
return $this->server->clients;
}
public function getByEID($eid){
$eid = (int) $eid;
$CID = $this->server->query("SELECT ip,port FROM players WHERE EID = '".$eid."';", true);
@ -112,6 +116,16 @@ class PlayerAPI{
return false;
}
public function getByClientID($clientID){
$clientID = (int) $clientID;
$CID = $this->server->query("SELECT ip,port FROM players WHERE clientID = '".$clientID."';", true);
$CID = $this->server->clientID($CID["ip"], $CID["port"]);
if(isset($this->server->clients[$CID])){
return $this->server->clients[$CID];
}
return false;
}
public function online(){
$o = array();
foreach($this->server->clients as $p){
@ -127,7 +141,7 @@ class PlayerAPI{
$player = $this->server->clients[$CID];
console("[INFO] Player \"".$player->username."\" connected from ".$player->ip.":".$player->port);
$player->data = $this->getOffline($player->username);
$this->server->query("INSERT OR REPLACE INTO players (clientID, EID, ip, port, name) VALUES (".$player->clientID.", ".$player->eid.", '".$player->ip."', ".$player->port.", '".$player->username."');");
$this->server->query("INSERT OR REPLACE INTO players (clientID, ip, port, name) VALUES (".$player->clientID.", '".$player->ip."', ".$player->port.", '".$player->username."');");
}
}