From a34595292d280843adcd0fb4ea957e25c443dafe Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Tue, 20 Aug 2013 11:23:55 +0200 Subject: [PATCH] Allow armor replacing (changing armor to another armor) --- src/API/PlayerAPI.php | 5 ++--- src/Player.php | 4 ++++ src/world/Entity.php | 4 ++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/API/PlayerAPI.php b/src/API/PlayerAPI.php index 07511a6aa..3aa857670 100644 --- a/src/API/PlayerAPI.php +++ b/src/API/PlayerAPI.php @@ -415,7 +415,6 @@ class PlayerAPI{ public function remove($CID){ if(isset($this->server->clients[$CID])){ $player = $this->server->clients[$CID]; - $this->server->clients[$CID] = null; unset($this->server->clients[$CID]); $player->close(); if($player->username != "" and ($player->data instanceof Config)){ @@ -423,8 +422,8 @@ class PlayerAPI{ } $this->server->query("DELETE FROM players WHERE name = '".$player->username."';"); if($player->entity instanceof Entity){ - $player->entity->player = null; - $player->entity = null; + unset($player->entity->player); + unset($player->entity); } $this->server->api->entity->remove($player->eid); $player = null; diff --git a/src/Player.php b/src/Player.php index d8dbe183f..ef3226cc4 100644 --- a/src/Player.php +++ b/src/Player.php @@ -1432,6 +1432,10 @@ class Player{ }elseif($s->getID() !== AIR and $slot->getID() === AIR and ($sl = $this->hasItem($s->getID())) !== false){ $this->armor[$i] = $this->getSlot($sl); $this->setSlot($sl, BlockAPI::getItem(AIR, 0, 0), false); + }elseif($s->getID() !== AIR and $slot->getID() !== AIR and ($sl = $this->hasItem($s->getID())) !== false){ + $item = $this->armor[$i]; + $this->armor[$i] = $this->getSlot($sl); + $this->setSlot($sl, $item, false); }else{ $data["slot$i"] = 255; } diff --git a/src/world/Entity.php b/src/world/Entity.php index 5d0bf93be..d96eabf0f 100644 --- a/src/world/Entity.php +++ b/src/world/Entity.php @@ -383,6 +383,10 @@ class Entity extends Position{ $this->tickCounter = 0; } + if($this->closed === true){ + return false; + } + if($this->isStatic === false){ $startX = floor($this->x - 0.5 - $this->size - 1); $y = (int) round($this->y - 1);