diff --git a/src/BaseEvent.php b/src/BaseEvent.php index 294ab14bac..c4a25a18a8 100644 --- a/src/BaseEvent.php +++ b/src/BaseEvent.php @@ -34,54 +34,6 @@ abstract class BaseEvent{ * Not doing so will deny the proper event initialization */ - protected $eventName = null; - private $status = BaseEvent::NORMAL; - private $prioritySlot; - - final public function getEventName(){ - return $this->eventName !== null ? get_class($this) : $this->eventName; - } - - final public function setPrioritySlot($slot){ - $this->prioritySlot = (int) $slot; - } - - final public function getPrioritySlot(){ - return (int) $this->prioritySlot; - } - - - public function isAllowed(){ - return ($this->status & 0x7FFFFFFF) === BaseEvent::ALLOW; - } - - public function setAllowed($forceAllow = false){ - $this->status = BaseEvent::ALLOW | ($forceAllow === true ? BaseEvent::FORCE : 0); - } - - public function isCancelled(){ - return ($this->status & 0x7FFFFFFF) === BaseEvent::DENY; - } - - public function setCancelled($forceCancel = false){ - if($this instanceof CancellableEvent){ - $this->status = BaseEvent::DENY | ($forceCancel === true ? BaseEvent::FORCE : 0); - } - return false; - } - - public function isNormal(){ - return $this->status === BaseEvent::NORMAL; - } - - public function setNormal(){ - $this->status = BaseEvent::NORMAL; - } - - public function isForced(){ - return ($this->status & BaseEvent::FORCE) > 0; - } - public static function getHandlerList(){ return static::$handlers; } @@ -131,6 +83,57 @@ abstract class BaseEvent{ }else{ return false; } + } + + + + + protected $eventName = null; + private $status = BaseEvent::NORMAL; + private $prioritySlot; + + final public function getEventName(){ + return $this->eventName !== null ? get_class($this) : $this->eventName; } + final public function setPrioritySlot($slot){ + $this->prioritySlot = (int) $slot; + } + + final public function getPrioritySlot(){ + return (int) $this->prioritySlot; + } + + + public function isAllowed(){ + return ($this->status & 0x7FFFFFFF) === BaseEvent::ALLOW; + } + + public function setAllowed($forceAllow = false){ + $this->status = BaseEvent::ALLOW | ($forceAllow === true ? BaseEvent::FORCE : 0); + } + + public function isCancelled(){ + return ($this->status & 0x7FFFFFFF) === BaseEvent::DENY; + } + + public function setCancelled($forceCancel = false){ + if($this instanceof CancellableEvent){ + $this->status = BaseEvent::DENY | ($forceCancel === true ? BaseEvent::FORCE : 0); + } + return false; + } + + public function isNormal(){ + return $this->status === BaseEvent::NORMAL; + } + + public function setNormal(){ + $this->status = BaseEvent::NORMAL; + } + + public function isForced(){ + return ($this->status & BaseEvent::FORCE) > 0; + } + } \ No newline at end of file diff --git a/src/event/EventHandler.php b/src/event/EventHandler.php index 2a9b1becd3..741cd3f080 100644 --- a/src/event/EventHandler.php +++ b/src/event/EventHandler.php @@ -22,6 +22,9 @@ abstract class EventHandler{ public static function callEvent(BaseEvent $event){ + if(count($event::$handlerPriority) === 0){ + return BaseEvent::NORMAL; + } foreach($event::$handlerPriority as $priority => $handlerList){ if(count($handlerList) > 0){ $event->setPrioritySlot($priority); @@ -45,7 +48,6 @@ abstract class EventHandler{ }else{ return BaseEvent::NORMAL; } - } } \ No newline at end of file diff --git a/src/event/PluginEvent.php b/src/event/PluginEvent.php index d7a483be33..289a2c382b 100644 --- a/src/event/PluginEvent.php +++ b/src/event/PluginEvent.php @@ -20,10 +20,14 @@ */ -/** - * Plugins that create events must use this class as the base - */ - abstract class PluginEvent extends BaseEvent{ - + private $plugin; + + public function __construct(Plugin $plugin){ + $this->plugin = $plugin; + } + + public function getPlugin(){ + return $this->plugin; + } } \ No newline at end of file