Created
June 4, 2020 21:45
-
-
Save PJZ9n/861c1487195fae2e12c6b7d017b2fb63 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
start($this)->run(function () { | |
$lastTick = []; | |
while (true) { | |
return; | |
/** @var PlayerInteractEvent $event */ | |
$event = yield listen(PlayerInteractEvent::class); | |
$player = $event->getPlayer(); | |
$name = $player->getName(); | |
$currentTick = $player->getServer()->getTick(); | |
if (!isset($lastTick[$name])) { | |
$lastTick[$name] = $currentTick; | |
return; | |
} | |
if ($currentTick - $lastTick[$name] < 10) { | |
$event->setCancelled(); | |
return; | |
} | |
$lastTick[$name] = $currentTick; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment