Player: allow provision of a custom cooldown duration for items

this would be more useful to plugins, so that it's not necessary to extend any item classes for this trivial purpose.
This commit is contained in:
Dylan K. Taylor 2020-04-15 09:32:48 +01:00
parent a2543ff80d
commit 51908ec45a

View File

@ -902,8 +902,8 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
/**
* Resets the player's cooldown time for the given item back to the maximum.
*/
public function resetItemCooldown(Item $item) : void{
$ticks = $item->getCooldownTicks();
public function resetItemCooldown(Item $item, ?int $ticks = null) : void{
$ticks = $ticks ?? $item->getCooldownTicks();
if($ticks > 0){
$this->usedItemsCooldown[$item->getId()] = $this->server->getTick() + $ticks;
}