mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Player: Fixed window ID of closing inventory always being -1
reported by @Muqsit, thank you sir
This commit is contained in:
parent
3e35bc38e2
commit
ef816c0a52
@ -3773,17 +3773,18 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
* @throws \BadMethodCallException if trying to remove a fixed inventory window without the `force` parameter as true
|
||||
*/
|
||||
public function removeWindow(Inventory $inventory, bool $force = false){
|
||||
if(isset($this->windows[$hash = spl_object_hash($inventory)])){
|
||||
/** @var int $id */
|
||||
$id = $this->windows[$hash];
|
||||
if(!$force and isset($this->permanentWindows[$id])){
|
||||
throw new \BadMethodCallException("Cannot remove fixed window $id (" . get_class($inventory) . ") from " . $this->getName());
|
||||
}
|
||||
$id = $this->windows[$hash = spl_object_hash($inventory)] ?? null;
|
||||
|
||||
unset($this->windows[$hash], $this->windowIndex[$id], $this->permanentWindows[$id]);
|
||||
if($id !== null and !$force and isset($this->permanentWindows[$id])){
|
||||
throw new \BadMethodCallException("Cannot remove fixed window $id (" . get_class($inventory) . ") from " . $this->getName());
|
||||
}
|
||||
|
||||
$inventory->close($this);
|
||||
|
||||
unset($this->windows[$hash]);
|
||||
if($id !== null){
|
||||
unset($this->windowIndex[$id], $this->permanentWindows[$id]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user