Skip to content

Commit

Permalink
Fixed server crash when applying item cooldown (pmmp#6491)
Browse files Browse the repository at this point in the history
This commit fixes server crash when applying a cooldown to any item which count is equals to 1.

closes pmmp#6490 
closes pmmp#6488
  • Loading branch information
ipad54 authored Nov 10, 2024
1 parent 231eec9 commit 2ff6470
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/player/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@ public function useHeldItem() : bool{
return false;
}

$this->resetItemCooldown($item);
$this->resetItemCooldown($oldItem);
$this->returnItemsFromAction($oldItem, $item, $returnedItems);

$this->setUsingItem($item instanceof Releasable && $item->canStartUsingItem($this));
Expand Down Expand Up @@ -1654,7 +1654,7 @@ public function consumeHeldItem() : bool{
}

$this->setUsingItem(false);
$this->resetItemCooldown($slot);
$this->resetItemCooldown($oldItem);

$slot->pop();
$this->returnItemsFromAction($oldItem, $slot, [$slot->getResidue()]);
Expand Down Expand Up @@ -1682,7 +1682,7 @@ public function releaseHeldItem() : bool{
$returnedItems = [];
$result = $item->onReleaseUsing($this, $returnedItems);
if($result === ItemUseResult::SUCCESS){
$this->resetItemCooldown($item);
$this->resetItemCooldown($oldItem);
$this->returnItemsFromAction($oldItem, $item, $returnedItems);
return true;
}
Expand Down

0 comments on commit 2ff6470

Please sign in to comment.