mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-07 12:18:46 +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
|
* @throws \BadMethodCallException if trying to remove a fixed inventory window without the `force` parameter as true
|
||||||
*/
|
*/
|
||||||
public function removeWindow(Inventory $inventory, bool $force = false){
|
public function removeWindow(Inventory $inventory, bool $force = false){
|
||||||
if(isset($this->windows[$hash = spl_object_hash($inventory)])){
|
$id = $this->windows[$hash = spl_object_hash($inventory)] ?? null;
|
||||||
/** @var int $id */
|
|
||||||
$id = $this->windows[$hash];
|
if($id !== null and !$force and isset($this->permanentWindows[$id])){
|
||||||
if(!$force and isset($this->permanentWindows[$id])){
|
|
||||||
throw new \BadMethodCallException("Cannot remove fixed window $id (" . get_class($inventory) . ") from " . $this->getName());
|
throw new \BadMethodCallException("Cannot remove fixed window $id (" . get_class($inventory) . ") from " . $this->getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
unset($this->windows[$hash], $this->windowIndex[$id], $this->permanentWindows[$id]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$inventory->close($this);
|
$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