Player: added getItemCooldownExpiry()

This commit is contained in:
Dylan K. Taylor
2020-11-03 14:11:28 +00:00
parent 2e9b2d4aae
commit bd78d0bff8
2 changed files with 10 additions and 0 deletions

View File

@ -111,6 +111,7 @@ use pocketmine\world\sound\EntityAttackSound;
use pocketmine\world\sound\FireExtinguishSound;
use pocketmine\world\World;
use function abs;
use function array_key_exists;
use function assert;
use function count;
use function explode;
@ -675,6 +676,14 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
return $this->startAction === -1 ? -1 : ($this->server->getTick() - $this->startAction);
}
/**
* Returns the server tick on which the player's cooldown period expires for the given item.
*/
public function getItemCooldownExpiry(Item $item) : int{
$this->checkItemCooldowns();
return $this->usedItemsCooldown[$item->getId()] ?? 0;
}
/**
* Returns whether the player has a cooldown period left before it can use the given item again.
*/