mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
33 lines
No EOL
744 B
PHP
33 lines
No EOL
744 B
PHP
<?php
|
|
|
|
abstract class EventHandler{
|
|
|
|
public static function callEvent(BaseEvent $event){
|
|
$status = BaseEvent::NORMAL;
|
|
foreach($event::$handlerPriority as $priority => $handlerList){
|
|
if(count($handlerList) > 0){
|
|
$event->setPrioritySlot($priority);
|
|
foreach($handlerList as $handler){
|
|
call_user_func($handler, $event);
|
|
}
|
|
if($event->isForced()){
|
|
if($event instanceof CancellableEvent and $event->isCancelled()){
|
|
return BaseEvent::DENY;
|
|
}else{
|
|
return BaseEvent::ALLOW;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if($event instanceof CancellableEvent and $event->isCancelled()){
|
|
return BaseEvent::DENY;
|
|
}elseif($event->isAllowed()){
|
|
return BaseEvent::ALLOW;
|
|
}else{
|
|
return BaseEvent::NORMAL;
|
|
}
|
|
|
|
}
|
|
|
|
} |