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{
$event = new PlayerEmoteEvent($this, $emoteId);
$event->call();
if(!$event->isCancelled() && $this->getServer()->getTick() - $this->lastEmoteTick > 5){
$this->lastEmoteTick = $this->getServer()->getTick();
foreach($this->getViewers() as $player){
$player->getNetworkSession()->onEmote($this, $emoteId);
$currentTick = $this->server->getTick();
if($currentTick - $this->lastEmoteTick > 5){
$this->lastEmoteTick = $currentTick;
$event = new PlayerEmoteEvent($this, $emoteId);
$event->call();
if(!$event->isCancelled()){
foreach($this->getViewers() as $player){
$player->getNetworkSession()->onEmote($this, $emoteId);
}
}
}
}