Do not call PlayerEmoteEvent if rate limit was reached

This commit is contained in:
Dylan K. Taylor 2021-11-02 23:09:43 +00:00
parent f066199971
commit 87031627bf
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -1731,12 +1731,15 @@ class Player extends Human implements CommandSender, ChunkListener, IPlayer{
} }
public function emote(string $emoteId) : void{ public function emote(string $emoteId) : void{
$event = new PlayerEmoteEvent($this, $emoteId); $currentTick = $this->server->getTick();
$event->call(); if($currentTick - $this->lastEmoteTick > 5){
if(!$event->isCancelled() && $this->getServer()->getTick() - $this->lastEmoteTick > 5){ $this->lastEmoteTick = $currentTick;
$this->lastEmoteTick = $this->getServer()->getTick(); $event = new PlayerEmoteEvent($this, $emoteId);
foreach($this->getViewers() as $player){ $event->call();
$player->getNetworkSession()->onEmote($this, $emoteId); if(!$event->isCancelled()){
foreach($this->getViewers() as $player){
$player->getNetworkSession()->onEmote($this, $emoteId);
}
} }
} }
} }