Skip to content

Commit 51a1408

Browse files
committed
Add getter methods to retrieve listener and inventory close listener
allows developers to retrieve the current listener, extend its behavior, and then re-set it. This provides more flexibility in chaining or extending listener functionalities without losing the original behavior. ```php $listener = $menu->getInventoryCloseListener(); $menu->setInventoryCloseListener(function(Player $player, Inventory $inventory) use($listener) : void{ $listener($player, $inventory); // place additional inventory close checks here }); ```
1 parent 9f0f6d9 commit 51a1408

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

src/muqsit/invmenu/InvMenu.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ public function setName(?string $name) : self{
8383
return $this;
8484
}
8585

86+
/**
87+
* @return (Closure(InvMenuTransaction) : InvMenuTransactionResult)|null
88+
*/
89+
public function getListener() : ?Closure{
90+
return $this->listener;
91+
}
92+
8693
/**
8794
* @param (Closure(InvMenuTransaction) : InvMenuTransactionResult)|null $listener
8895
* @return self
@@ -92,6 +99,13 @@ public function setListener(?Closure $listener) : self{
9299
return $this;
93100
}
94101

102+
/**
103+
* @return (Closure(Player, Inventory) : void)|null
104+
*/
105+
public function getInventoryCloseListener() : ?Closure{
106+
return $this->inventory_close_listener;
107+
}
108+
95109
/**
96110
* @param (Closure(Player, Inventory) : void)|null $listener
97111
* @return self

0 commit comments

Comments
 (0)