Skip to content

Instantly share code, notes, and snippets.

@PJZ9n
Created June 4, 2020 21:45
Show Gist options
  • Save PJZ9n/861c1487195fae2e12c6b7d017b2fb63 to your computer and use it in GitHub Desktop.
Save PJZ9n/861c1487195fae2e12c6b7d017b2fb63 to your computer and use it in GitHub Desktop.
<?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