mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Improved inventory and window allocation, fixes #2200
This commit is contained in:
@ -794,10 +794,12 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
* @return boolean
|
||||
*/
|
||||
public function sleepOn(Vector3 $pos){
|
||||
foreach($this->level->getPlayers() as $p){
|
||||
if($p->sleeping instanceof Vector3){
|
||||
if($pos->distance($p->sleeping) <= 0.1){
|
||||
return false;
|
||||
foreach($this->level->getNearbyEntities($this->boundingBox->grow(2, 1, 2), $this) as $p){
|
||||
if($p instanceof Player){
|
||||
if($p->sleeping instanceof Vector3){
|
||||
if($pos->distance($p->sleeping) <= 0.1){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2273,10 +2275,13 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
}
|
||||
}
|
||||
|
||||
foreach($this->windowIndex as $window){
|
||||
$this->removeWindow($window);
|
||||
}
|
||||
|
||||
$this->interface->close($this, $reason);
|
||||
$this->level->freeAllChunks($this);
|
||||
|
||||
|
||||
parent::close();
|
||||
|
||||
$this->loggedIn = false;
|
||||
@ -2284,6 +2289,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
if(isset($ev) and $this->username != "" and $this->spawned !== false and $ev->getQuitMessage() != ""){
|
||||
$this->server->broadcastMessage($ev->getQuitMessage());
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->unsubscribeFromPermission(Server::BROADCAST_CHANNEL_USERS, $this);
|
||||
$this->spawned = false;
|
||||
$this->server->getLogger()->info(TextFormat::AQUA . $this->username . TextFormat::WHITE . "[/" . $this->ip . ":" . $this->port . "] logged out due to " . str_replace(["\n", "\r"], [" ", ""], $reason));
|
||||
@ -2514,6 +2520,14 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
public function teleport(Vector3 $pos, $yaw = null, $pitch = null){
|
||||
if(parent::teleport($pos, $yaw, $pitch)){
|
||||
|
||||
foreach($this->windowIndex as $window){
|
||||
if($window === $this->inventory){
|
||||
continue;
|
||||
}
|
||||
$this->removeWindow($window);
|
||||
}
|
||||
|
||||
$this->airTicks = 300;
|
||||
$this->fallDistance = 0;
|
||||
$this->orderChunks();
|
||||
|
Reference in New Issue
Block a user