31 public function __construct(
32 private \Closure $handler,
33 private int $priority,
35 private bool $handleCancelled,
38 if(!in_array($priority, EventPriority::ALL,
true)){
39 throw new \InvalidArgumentException(
"Invalid priority number $priority");
43 public function getHandler() : \Closure{
44 return $this->handler;
47 public function getPlugin() :
Plugin{
51 public function getPriority() :
int{
52 return $this->priority;
55 public function callEvent(
Event $event) :
void{
56 if($event instanceof
Cancellable && $event->isCancelled() && !$this->isHandlingCancelled()){
59 $this->timings->startTiming();
61 ($this->handler)($event);
63 $this->timings->stopTiming();
67 public function isHandlingCancelled() :
bool{
68 return $this->handleCancelled;