Item change protection

This commit is contained in:
Shoghi Cervantes Pueyo 2013-04-13 13:37:14 +02:00
parent 8d7fafe167
commit c334bbce12

View File

@ -815,7 +815,7 @@ class Player{
$data["eid"] = $this->eid;
$data["player"] = $this;
$data["item"] = BlockAPI::getItem($data["block"], $data["meta"]);
if($this->server->handle("player.equipment.change", $data) !== false){
if(!$this->hasItem($data["block"], $data["meta"]) and $this->server->getProperty("disallow-crafting") === true and $this->server->handle("player.equipment.change", $data) !== false){
$this->equipment = $data["item"];
}
break;
@ -831,11 +831,8 @@ class Player{
$data["eid"] = $this->eid;
if($this->blocked === true or Utils::distance($this->entity->position, $data) > 10){
break;
}elseif(($this->gamemode === SURVIVAL or $this->gamemode === ADVENTURE) and !$this->hasItem($data["block"], $data["meta"])){
console("[DEBUG] Player \"".$this->username."\" tried to place not got block (or crafted block)", true, true, 2);
if($this->server->getProperty("disallow-crafting") === true){
break;
}
}elseif(($this->gamemode === SURVIVAL or $this->gamemode === ADVENTURE) and !$this->hasItem($data["block"], $data["meta"]) and $this->server->getProperty("disallow-crafting") === true){
break;
}
$this->server->api->block->playerBlockAction($this, new Vector3($data["x"], $data["y"], $data["z"]), $data["face"], $data["fx"], $data["fy"], $data["fz"]);
break;