Skip to content

Commit 9d35c75

Browse files
committed
Fix possible dupe glitch
1 parent 579f6f9 commit 9d35c75

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/muqsit/invmenu/InvMenuEventHandler.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,18 @@ public function onInventoryTransaction(InventoryTransactionEvent $event) : void{
6262

6363
$player_instance = $this->player_manager->get($player);
6464
$current = $player_instance->getCurrent();
65-
if($current === null){
66-
foreach($transaction->getActions() as $action){
67-
if($action instanceof SlotChangeAction && $action->getInventory() instanceof InvMenuInventory){
68-
$event->cancel();
69-
return;
70-
}
71-
}
72-
return;
73-
}
74-
75-
$inventory = $current->menu->getInventory();
65+
$inventory = $current?->menu->getInventory();
7666
$network_stack_callbacks = [];
7767
foreach($transaction->getActions() as $action){
78-
if(!($action instanceof SlotChangeAction) || $action->getInventory() !== $inventory){
68+
if(!($action instanceof SlotChangeAction)){
69+
continue;
70+
}
71+
72+
if($action->getInventory() !== $inventory){
73+
if($action->getInventory() instanceof InvMenuInventory){
74+
$event->cancel();
75+
return;
76+
}
7977
continue;
8078
}
8179

0 commit comments

Comments
 (0)