Implemented event handler inheritance, allow registering handlers for any valid event (#1792)

* Event handlers always handle subclass events. public static $handlerList no longer required.
* Removed $handlerList declarations
* HandlerList cleanup: Removed HandlerList->handlers and related bake methods
* Removed obsolete Event->getHandlers()
* EventPriority: Added fromString()
* PluginManager: throw exceptions on registering handlers with invalid priorities

This allows specifying a handler of `EntityDamageEvent` which will handle any instanceof it (as per current behaviour), AND also now allows specifying a handler specifically for `EntityDamageByEntityEvent`, which only handles `EntityDamageEvent`.

This was not previously possible due to limitations in the way handlers were registered.

Abstract events may not be handled unless they declare the `@allowHandle` PhpDoc tag.
This commit is contained in:
SOFe 2018-03-21 01:05:09 +08:00 committed by Dylan K. Taylor
parent 1648fff916
commit 49fbbea7bf
106 changed files with 204 additions and 363 deletions

View File

@ -28,14 +28,6 @@ namespace pocketmine\event;
abstract class Event{
/**
* Any callable event must declare the static variable
*
* public static $handlerList = null;
*
* Not doing so will deny the proper event initialization
*/
/** @var string|null */
protected $eventName = null;
/** @var bool */
@ -75,16 +67,4 @@ abstract class Event{
/** @var Event $this */
$this->isCancelled = $value;
}
/**
* @return HandlerList
*/
public function getHandlers() : HandlerList{
if(static::$handlerList === null){
static::$handlerList = new HandlerList();
}
return static::$handlerList;
}
}

View File

@ -33,6 +33,15 @@ namespace pocketmine\event;
* MONITOR events should not change the event outcome or contents
*/
abstract class EventPriority{
public const ALL = [
self::LOWEST,
self::LOW,
self::NORMAL,
self::HIGH,
self::HIGHEST,
self::MONITOR
];
/**
* Event call is of very low importance and should be ran first, to allow
* other plugins to further customise the outcome
@ -43,7 +52,8 @@ abstract class EventPriority{
*/
public const LOW = 4;
/**
* Event call is neither important or unimportant, and may be ran normally
* Event call is neither important or unimportant, and may be ran normally.
* This is the default priority.
*/
public const NORMAL = 3;
/**
@ -62,4 +72,20 @@ abstract class EventPriority{
*/
public const MONITOR = 0;
/**
* @param string $name
*
* @return int
*
* @throws \InvalidArgumentException
*/
public static function fromString(string $name) : int{
$name = strtoupper($name);
$const = self::class . "::" . $name;
if($name !== "ALL" and \defined($const)){
return \constant($const);
}
throw new \InvalidArgumentException("Unable to resolve priority \"$name\"");
}
}

View File

@ -24,38 +24,22 @@ declare(strict_types=1);
namespace pocketmine\event;
use pocketmine\plugin\Plugin;
use pocketmine\plugin\PluginManager;
use pocketmine\plugin\RegisteredListener;
class HandlerList{
/**
* @var RegisteredListener[]
*/
private $handlers = null;
/**
* @var RegisteredListener[][]
*/
private $handlerSlots = [];
/**
* @var HandlerList[]
* @var HandlerList[] classname => HandlerList
*/
private static $allLists = [];
public static function bakeAll(){
foreach(self::$allLists as $h){
$h->bake();
}
}
/**
* Unregisters all the listeners
* If a Plugin or Listener is passed, all the listeners with that object will be removed
*
* @param Plugin|Listener|null $object
*/
public static function unregisterAll($object = null){
public static function unregisterAll($object = null) : void{
if($object instanceof Listener or $object instanceof Plugin){
foreach(self::$allLists as $h){
$h->unregister($object);
@ -65,110 +49,41 @@ class HandlerList{
foreach($h->handlerSlots as $key => $list){
$h->handlerSlots[$key] = [];
}
$h->handlers = null;
}
}
}
public function __construct(){
$this->handlerSlots = [
EventPriority::LOWEST => [],
EventPriority::LOW => [],
EventPriority::NORMAL => [],
EventPriority::HIGH => [],
EventPriority::HIGHEST => [],
EventPriority::MONITOR => []
];
self::$allLists[] = $this;
}
/**
* @param RegisteredListener $listener
* Returns the HandlerList for listeners that explicitly handle this event.
*
* @throws \Exception
*/
public function register(RegisteredListener $listener){
if($listener->getPriority() < EventPriority::MONITOR or $listener->getPriority() > EventPriority::LOWEST){
return;
}
if(isset($this->handlerSlots[$listener->getPriority()][spl_object_hash($listener)])){
throw new \InvalidStateException("This listener is already registered to priority " . $listener->getPriority());
}
$this->handlers = null;
$this->handlerSlots[$listener->getPriority()][spl_object_hash($listener)] = $listener;
}
/**
* @param RegisteredListener[] $listeners
*/
public function registerAll(array $listeners){
foreach($listeners as $listener){
$this->register($listener);
}
}
/**
* @param RegisteredListener|Listener|Plugin $object
*/
public function unregister($object){
if($object instanceof Plugin or $object instanceof Listener){
$changed = false;
foreach($this->handlerSlots as $priority => $list){
foreach($list as $hash => $listener){
if(($object instanceof Plugin and $listener->getPlugin() === $object)
or ($object instanceof Listener and $listener->getListener() === $object)
){
unset($this->handlerSlots[$priority][$hash]);
$changed = true;
}
}
}
if($changed){
$this->handlers = null;
}
}elseif($object instanceof RegisteredListener){
if(isset($this->handlerSlots[$object->getPriority()][spl_object_hash($object)])){
unset($this->handlerSlots[$object->getPriority()][spl_object_hash($object)]);
$this->handlers = null;
}
}
}
public function bake(){
if($this->handlers !== null){
return;
}
$entries = [];
foreach($this->handlerSlots as $list){
foreach($list as $hash => $listener){
$entries[$hash] = $listener;
}
}
$this->handlers = $entries;
}
/**
* @param null|Plugin $plugin
* Calling this method also lazily initializes the $classMap inheritance tree of handler lists.
*
* @return RegisteredListener[]
* @param string $event
*
* @return null|HandlerList
* @throws \ReflectionException
*/
public function getRegisteredListeners($plugin = null) : array{
if($plugin !== null){
$listeners = [];
foreach($this->getRegisteredListeners(null) as $hash => $listener){
if($listener->getPlugin() === $plugin){
$listeners[$hash] = $plugin;
}
}
return $listeners;
}else{
while(($handlers = $this->handlers) === null){
$this->bake();
}
return $handlers;
public static function getHandlerListFor(string $event) : ?HandlerList{
if(isset(self::$allLists[$event])){
return self::$allLists[$event];
}
$class = new \ReflectionClass($event);
$tags = PluginManager::parseDocComment((string) $class->getDocComment());
if($class->isAbstract() && !isset($tags["allowHandle"])){
return null;
}
$super = $class;
$parentList = null;
while($parentList === null && ($super = $super->getParentClass()) !== false){
// skip $noHandle events in the inheritance tree to go to the nearest ancestor
// while loop to allow skipping $noHandle events in the inheritance tree
$parentList = self::getHandlerListFor($super->getName());
}
return new HandlerList($event, $parentList);
}
/**
@ -178,4 +93,79 @@ class HandlerList{
return self::$allLists;
}
/** @var string */
private $class;
/** @var RegisteredListener[][] */
private $handlerSlots = [];
/** @var HandlerList|null */
private $parentList;
public function __construct(string $class, ?HandlerList $parentList){
$this->class = $class;
$this->handlerSlots = array_fill_keys(EventPriority::ALL, []);
$this->parentList = $parentList;
self::$allLists[$this->class] = $this;
}
/**
* @param RegisteredListener $listener
*
* @throws \Exception
*/
public function register(RegisteredListener $listener) : void{
if(!in_array($listener->getPriority(), EventPriority::ALL, true)){
return;
}
if(isset($this->handlerSlots[$listener->getPriority()][spl_object_hash($listener)])){
throw new \InvalidStateException("This listener is already registered to priority {$listener->getPriority()} of event {$this->class}");
}
$this->handlerSlots[$listener->getPriority()][spl_object_hash($listener)] = $listener;
}
/**
* @param RegisteredListener[] $listeners
*/
public function registerAll(array $listeners) : void{
foreach($listeners as $listener){
$this->register($listener);
}
}
/**
* @param RegisteredListener|Listener|Plugin $object
*/
public function unregister($object) : void{
if($object instanceof Plugin or $object instanceof Listener){
foreach($this->handlerSlots as $priority => $list){
foreach($list as $hash => $listener){
if(($object instanceof Plugin and $listener->getPlugin() === $object)
or ($object instanceof Listener and $listener->getListener() === $object)
){
unset($this->handlerSlots[$priority][$hash]);
}
}
}
}elseif($object instanceof RegisteredListener){
if(isset($this->handlerSlots[$object->getPriority()][spl_object_hash($object)])){
unset($this->handlerSlots[$object->getPriority()][spl_object_hash($object)]);
}
}
}
/**
* @param int $priority
*
* @return RegisteredListener[]
*/
public function getListenersByPriority(int $priority) : array{
return $this->handlerSlots[$priority];
}
/**
* @return null|HandlerList
*/
public function getParent() : ?HandlerList{
return $this->parentList;
}
}

View File

@ -32,8 +32,6 @@ use pocketmine\Player;
* Called when a player destroys a block somewhere in the world.
*/
class BlockBreakEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
/** @var Player */
protected $player;

View File

@ -24,6 +24,5 @@ declare(strict_types=1);
namespace pocketmine\event\block;
class BlockFormEvent extends BlockGrowEvent{
public static $handlerList = null;
}

View File

@ -30,8 +30,6 @@ use pocketmine\event\Cancellable;
* Called when plants or crops grow.
*/
class BlockGrowEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
/** @var Block */
private $newState;

View File

@ -32,8 +32,6 @@ use pocketmine\Player;
* Called when a player places a block
*/
class BlockPlaceEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
/** @var Player */
protected $player;

View File

@ -29,8 +29,6 @@ use pocketmine\block\Block;
* Called when a block spreads to another block, such as grass spreading to nearby dirt blocks.
*/
class BlockSpreadEvent extends BlockFormEvent{
public static $handlerList = null;
/** @var Block */
private $source;

View File

@ -29,6 +29,5 @@ use pocketmine\event\Cancellable;
* Called when a block tries to be updated due to a neighbor change
*/
class BlockUpdateEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
}

View File

@ -29,6 +29,5 @@ use pocketmine\event\Cancellable;
* Called when leaves decay due to not being attached to wood.
*/
class LeavesDecayEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
}

View File

@ -31,8 +31,6 @@ use pocketmine\Player;
* Called when a sign is changed by a player.
*/
class SignChangeEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
/** @var Player */
private $player;
/** @var string[] */

View File

@ -24,6 +24,5 @@ declare(strict_types=1);
namespace pocketmine\event\entity;
class EntityArmorChangeEvent extends EntityInventoryChangeEvent{
public static $handlerList = null;
}

View File

@ -31,8 +31,6 @@ use pocketmine\event\Cancellable;
* Called when an Entity, excluding players, changes a block directly
*/
class EntityBlockChangeEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
/** @var Block */
private $from;
/** @var Block */

View File

@ -27,7 +27,6 @@ use pocketmine\block\Block;
use pocketmine\entity\Entity;
class EntityCombustByBlockEvent extends EntityCombustEvent{
/** @var Block */
protected $combuster;

View File

@ -26,7 +26,6 @@ namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
class EntityCombustByEntityEvent extends EntityCombustEvent{
/** @var Entity */
protected $combuster;

View File

@ -27,8 +27,6 @@ use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
class EntityCombustEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
protected $duration;
/**

View File

@ -30,11 +30,9 @@ use pocketmine\entity\Entity;
* Called when an entity takes damage from a block.
*/
class EntityDamageByBlockEvent extends EntityDamageEvent{
/** @var Block */
private $damager;
/**
* @param Block $damager
* @param Entity $entity

View File

@ -29,7 +29,6 @@ use pocketmine\entity\Entity;
* Called when an entity takes damage from an entity sourced from another entity, for example being hit by a snowball thrown by a Player.
*/
class EntityDamageByChildEntityEvent extends EntityDamageByEntityEvent{
/** @var int */
private $childEntityEid;

View File

@ -31,7 +31,6 @@ use pocketmine\entity\Living;
* Called when an entity takes damage from another entity.
*/
class EntityDamageByEntityEvent extends EntityDamageEvent{
/** @var int */
private $damagerEntityId;
/** @var float */

View File

@ -30,8 +30,6 @@ use pocketmine\event\Cancellable;
* Called when an entity takes damage.
*/
class EntityDamageEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public const MODIFIER_BASE = 0;
public const MODIFIER_ARMOR = 1;
public const MODIFIER_STRENGTH = 2;

View File

@ -27,12 +27,9 @@ use pocketmine\entity\Living;
use pocketmine\item\Item;
class EntityDeathEvent extends EntityEvent{
public static $handlerList = null;
/** @var Item[] */
private $drops = [];
/**
* @param Living $entity
* @param Item[] $drops

View File

@ -34,8 +34,6 @@ use pocketmine\entity\Vehicle;
* Called when a entity is despawned
*/
class EntityDespawnEvent extends EntityEvent{
public static $handlerList = null;
/** @var int */
private $entityType;

View File

@ -30,8 +30,6 @@ use pocketmine\entity\Entity;
* Called when an effect is added to an Entity.
*/
class EntityEffectAddEvent extends EntityEffectEvent{
public static $handlerList = null;
/** @var EffectInstance|null */
private $oldEffect;

View File

@ -28,7 +28,6 @@ use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
class EntityEffectEvent extends EntityEvent implements Cancellable{
/** @var EffectInstance */
private $effect;

View File

@ -27,8 +27,6 @@ namespace pocketmine\event\entity;
* Called when an effect is removed from an entity.
*/
class EntityEffectRemoveEvent extends EntityEffectEvent{
public static $handlerList = null;
public function setCancelled(bool $value = true){
if($this->getEffect()->getDuration() <= 0){
throw new \InvalidStateException("Removal of expired effects cannot be cancelled");

View File

@ -32,8 +32,6 @@ use pocketmine\level\Position;
* Called when a entity explodes
*/
class EntityExplodeEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
/** @var Position */
protected $position;

View File

@ -31,8 +31,6 @@ use pocketmine\item\Item;
* Called before a slot in an entity's inventory changes.
*/
class EntityInventoryChangeEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
/** @var Item */
private $oldItem;
/** @var Item */

View File

@ -28,8 +28,6 @@ use pocketmine\event\Cancellable;
use pocketmine\level\Level;
class EntityLevelChangeEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
/** @var Level */
private $originLevel;
/** @var Level */

View File

@ -28,8 +28,6 @@ use pocketmine\event\Cancellable;
use pocketmine\math\Vector3;
class EntityMotionEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
/** @var Vector3 */
private $mot;

View File

@ -27,8 +27,6 @@ use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
class EntityRegainHealthEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public const CAUSE_REGEN = 0;
public const CAUSE_EATING = 1;
public const CAUSE_MAGIC = 2;

View File

@ -30,8 +30,6 @@ use pocketmine\event\Cancellable;
use pocketmine\item\Item;
class EntityShootBowEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
/** @var Item */
private $bow;
/** @var Projectile */

View File

@ -35,8 +35,6 @@ use pocketmine\level\Position;
* Called when a entity is spawned
*/
class EntitySpawnEvent extends EntityEvent{
public static $handlerList = null;
/** @var int */
private $entityType;

View File

@ -28,8 +28,6 @@ use pocketmine\event\Cancellable;
use pocketmine\level\Position;
class EntityTeleportEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
/** @var Position */
private $from;
/** @var Position */

View File

@ -30,8 +30,6 @@ use pocketmine\event\Cancellable;
* Called when a entity decides to explode
*/
class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
/** @var float */
protected $force;
/** @var bool */

View File

@ -27,7 +27,6 @@ use pocketmine\entity\object\ItemEntity;
use pocketmine\event\Cancellable;
class ItemDespawnEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
/**
* @param ItemEntity $item

View File

@ -26,7 +26,6 @@ namespace pocketmine\event\entity;
use pocketmine\entity\object\ItemEntity;
class ItemSpawnEvent extends EntityEvent{
public static $handlerList = null;
/**
* @param ItemEntity $item

View File

@ -28,7 +28,6 @@ use pocketmine\entity\projectile\Projectile;
use pocketmine\math\RayTraceResult;
class ProjectileHitBlockEvent extends ProjectileHitEvent{
/** @var Block */
private $blockHit;

View File

@ -28,7 +28,6 @@ use pocketmine\entity\projectile\Projectile;
use pocketmine\math\RayTraceResult;
class ProjectileHitEntityEvent extends ProjectileHitEvent{
/** @var Entity */
private $entityHit;

View File

@ -26,9 +26,10 @@ namespace pocketmine\event\entity;
use pocketmine\entity\projectile\Projectile;
use pocketmine\math\RayTraceResult;
/**
* @allowHandle
*/
abstract class ProjectileHitEvent extends EntityEvent{
public static $handlerList = null;
/** @var RayTraceResult */
private $rayTraceResult;

View File

@ -27,8 +27,6 @@ use pocketmine\entity\projectile\Projectile;
use pocketmine\event\Cancellable;
class ProjectileLaunchEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
/**
* @param Projectile $entity
*/

View File

@ -31,8 +31,6 @@ use pocketmine\item\Item;
use pocketmine\Player;
class CraftItemEvent extends Event implements Cancellable{
public static $handlerList = null;
/** @var CraftingTransaction */
private $transaction;

View File

@ -29,8 +29,6 @@ use pocketmine\item\Item;
use pocketmine\tile\Furnace;
class FurnaceBurnEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
/** @var Furnace */
private $furnace;
/** @var Item */

View File

@ -29,8 +29,6 @@ use pocketmine\item\Item;
use pocketmine\tile\Furnace;
class FurnaceSmeltEvent extends BlockEvent implements Cancellable{
public static $handlerList = null;
/** @var Furnace */
private $furnace;
/** @var Item */

View File

@ -27,8 +27,6 @@ use pocketmine\inventory\Inventory;
use pocketmine\Player;
class InventoryCloseEvent extends InventoryEvent{
public static $handlerList = null;
/** @var Player */
private $who;

View File

@ -31,7 +31,6 @@ use pocketmine\event\Event;
use pocketmine\inventory\Inventory;
abstract class InventoryEvent extends Event{
/** @var Inventory */
protected $inventory;

View File

@ -28,8 +28,6 @@ use pocketmine\inventory\Inventory;
use pocketmine\Player;
class InventoryOpenEvent extends InventoryEvent implements Cancellable{
public static $handlerList = null;
/** @var Player */
private $who;

View File

@ -28,8 +28,6 @@ use pocketmine\event\Cancellable;
use pocketmine\inventory\Inventory;
class InventoryPickupArrowEvent extends InventoryEvent implements Cancellable{
public static $handlerList = null;
/** @var Arrow */
private $arrow;

View File

@ -28,8 +28,6 @@ use pocketmine\event\Cancellable;
use pocketmine\inventory\Inventory;
class InventoryPickupItemEvent extends InventoryEvent implements Cancellable{
public static $handlerList = null;
/** @var ItemEntity */
private $item;

View File

@ -32,8 +32,6 @@ use pocketmine\inventory\transaction\InventoryTransaction;
* The source of this can be a Player, entities, mobs, or even hoppers in the future!
*/
class InventoryTransactionEvent extends Event implements Cancellable{
public static $handlerList = null;
/** @var InventoryTransaction */
private $transaction;

View File

@ -31,8 +31,6 @@ use pocketmine\level\Level;
* Called when a Chunk is loaded
*/
class ChunkLoadEvent extends ChunkEvent{
public static $handlerList = null;
/** @var bool */
private $newChunk;

View File

@ -27,5 +27,5 @@ namespace pocketmine\event\level;
* Called when a Chunk is populated (after receiving it on the main thread)
*/
class ChunkPopulateEvent extends ChunkEvent{
public static $handlerList = null;
}

View File

@ -29,5 +29,5 @@ use pocketmine\event\Cancellable;
* Called when a Chunk is unloaded
*/
class ChunkUnloadEvent extends ChunkEvent implements Cancellable{
public static $handlerList = null;
}

View File

@ -27,5 +27,5 @@ namespace pocketmine\event\level;
* Called when a Level is initializing
*/
class LevelInitEvent extends LevelEvent{
public static $handlerList = null;
}

View File

@ -27,5 +27,5 @@ namespace pocketmine\event\level;
* Called when a Level is loaded
*/
class LevelLoadEvent extends LevelEvent{
public static $handlerList = null;
}

View File

@ -27,5 +27,5 @@ namespace pocketmine\event\level;
* Called when a Level is saved
*/
class LevelSaveEvent extends LevelEvent{
public static $handlerList = null;
}

View File

@ -29,5 +29,5 @@ use pocketmine\event\Cancellable;
* Called when a Level is unloaded
*/
class LevelUnloadEvent extends LevelEvent implements Cancellable{
public static $handlerList = null;
}

View File

@ -31,8 +31,6 @@ use pocketmine\level\Position;
* The previous spawn is included
*/
class SpawnChangeEvent extends LevelEvent{
public static $handlerList = null;
/** @var Position */
private $previousSpawn;

View File

@ -30,8 +30,6 @@ use pocketmine\Player;
* Called when a player is awarded an achievement
*/
class PlayerAchievementAwardedEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var string */
protected $achievement;

View File

@ -30,8 +30,6 @@ use pocketmine\Player;
* Called when a player does an animation
*/
class PlayerAnimationEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var int */
private $animationType;

View File

@ -28,8 +28,6 @@ use pocketmine\event\Cancellable;
use pocketmine\Player;
class PlayerBedEnterEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var Block */
private $bed;

View File

@ -27,8 +27,6 @@ use pocketmine\block\Block;
use pocketmine\Player;
class PlayerBedLeaveEvent extends PlayerEvent{
public static $handlerList = null;
/** @var Block */
private $bed;

View File

@ -32,8 +32,6 @@ use pocketmine\Player;
* Called when a player middle-clicks on a block to get an item in creative mode.
*/
class PlayerBlockPickEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var Block */
private $blockClicked;
/** @var Item */

View File

@ -24,6 +24,5 @@ declare(strict_types=1);
namespace pocketmine\event\player;
class PlayerBucketEmptyEvent extends PlayerBucketEvent{
public static $handlerList = null;
}

View File

@ -28,8 +28,10 @@ use pocketmine\event\Cancellable;
use pocketmine\item\Item;
use pocketmine\Player;
/**
* @allowHandle
*/
abstract class PlayerBucketEvent extends PlayerEvent implements Cancellable{
/** @var Block */
private $blockClicked;
/** @var int */

View File

@ -24,5 +24,5 @@ declare(strict_types=1);
namespace pocketmine\event\player;
class PlayerBucketFillEvent extends PlayerBucketEvent{
public static $handlerList = null;
}

View File

@ -31,8 +31,6 @@ use pocketmine\Player;
* Called when a player changes their skin in-game.
*/
class PlayerChangeSkinEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var Skin */
private $oldSkin;
/** @var Skin */

View File

@ -31,8 +31,6 @@ use pocketmine\Server;
* Called when a player chats something
*/
class PlayerChatEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var string */
protected $message;

View File

@ -35,8 +35,6 @@ use pocketmine\Player;
* The message contains a slash at the start
*/
class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var string */
protected $message;

View File

@ -31,8 +31,6 @@ use pocketmine\Player;
* Allows the creation of players overriding the base Player class
*/
class PlayerCreationEvent extends Event{
public static $handlerList = null;
/** @var SourceInterface */
private $interface;
/** @var string */

View File

@ -33,8 +33,6 @@ use pocketmine\Server;
* Called when a player's data is about to be saved to disk.
*/
class PlayerDataSaveEvent extends Event implements Cancellable{
public static $handlerList = null;
/** @var CompoundTag */
protected $data;
/** @var string */

View File

@ -29,8 +29,6 @@ use pocketmine\lang\TextContainer;
use pocketmine\Player;
class PlayerDeathEvent extends EntityDeathEvent{
public static $handlerList = null;
/** @var Player */
protected $entity;

View File

@ -31,8 +31,6 @@ use pocketmine\Player;
* Called when a player tries to drop an item from its hotbar
*/
class PlayerDropItemEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var Item */
private $drop;

View File

@ -28,8 +28,6 @@ use pocketmine\item\WritableBook;
use pocketmine\Player;
class PlayerEditBookEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
public const ACTION_REPLACE_PAGE = 0;
public const ACTION_ADD_PAGE = 1;
public const ACTION_DELETE_PAGE = 2;

View File

@ -28,8 +28,6 @@ use pocketmine\event\Cancellable;
use pocketmine\event\entity\EntityEvent;
class PlayerExhaustEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
public const CAUSE_ATTACK = 1;
public const CAUSE_DAMAGE = 2;
public const CAUSE_MINING = 3;

View File

@ -30,8 +30,6 @@ use pocketmine\Player;
* Called when a player has its gamemode changed
*/
class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var int */
protected $gamemode;

View File

@ -35,8 +35,6 @@ use pocketmine\Player;
* Called when a player interacts or touches a block (including air?)
*/
class PlayerInteractEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
public const LEFT_CLICK_BLOCK = 0;
public const RIGHT_CLICK_BLOCK = 1;
public const LEFT_CLICK_AIR = 2;

View File

@ -31,8 +31,6 @@ use pocketmine\Player;
* Called when a player eats something
*/
class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var Item */
private $item;

View File

@ -28,8 +28,6 @@ use pocketmine\item\Item;
use pocketmine\Player;
class PlayerItemHeldEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var Item */
private $item;
/** @var int */

View File

@ -30,8 +30,6 @@ use pocketmine\Player;
* Called when a player joins the server, after sending all the spawn packets
*/
class PlayerJoinEvent extends PlayerEvent{
public static $handlerList = null;
/** @var string|TextContainer */
protected $joinMessage;

View File

@ -29,7 +29,6 @@ use pocketmine\Player;
* Called when a player jumps
*/
class PlayerJumpEvent extends PlayerEvent{
public static $handlerList = null;
/**
* PlayerJumpEvent constructor.

View File

@ -31,8 +31,6 @@ use pocketmine\Player;
* Called when a player leaves the server
*/
class PlayerKickEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var TextContainer|string */
protected $quitMessage;

View File

@ -30,8 +30,6 @@ use pocketmine\Player;
* Called when a player joins, after things have been correctly set up (you can change anything now)
*/
class PlayerLoginEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var string */
protected $kickMessage;

View File

@ -28,8 +28,6 @@ use pocketmine\level\Location;
use pocketmine\Player;
class PlayerMoveEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var Location */
private $from;
/** @var Location */

View File

@ -30,8 +30,6 @@ use pocketmine\Player;
* Called when the player logs in, before things have been set up
*/
class PlayerPreLoginEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var string */
protected $kickMessage;

View File

@ -30,7 +30,6 @@ use pocketmine\Player;
* Called when a player leaves the server
*/
class PlayerQuitEvent extends PlayerEvent{
public static $handlerList = null;
/** @var TranslationContainer|string */
protected $quitMessage;

View File

@ -30,8 +30,6 @@ use pocketmine\Player;
* Called when a player is respawned (or first time spawned)
*/
class PlayerRespawnEvent extends PlayerEvent{
public static $handlerList = null;
/** @var Position */
protected $position;

View File

@ -27,8 +27,6 @@ use pocketmine\event\Cancellable;
use pocketmine\Player;
class PlayerToggleFlightEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var bool */
protected $isFlying;

View File

@ -27,8 +27,6 @@ use pocketmine\event\Cancellable;
use pocketmine\Player;
class PlayerToggleSneakEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var bool */
protected $isSneaking;

View File

@ -27,8 +27,6 @@ use pocketmine\event\Cancellable;
use pocketmine\Player;
class PlayerToggleSprintEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var bool */
protected $isSprinting;

View File

@ -27,8 +27,6 @@ use pocketmine\event\Cancellable;
use pocketmine\Player;
class PlayerTransferEvent extends PlayerEvent implements Cancellable{
public static $handlerList = null;
/** @var string */
protected $address;
/** @var int */

View File

@ -28,6 +28,9 @@ namespace pocketmine\event\player\cheat;
use pocketmine\event\player\PlayerEvent;
/**
* @allowHandle
*/
abstract class PlayerCheatEvent extends PlayerEvent{
}

View File

@ -32,7 +32,6 @@ use pocketmine\Player;
* Called when a player attempts to perform movement cheats such as clipping through blocks.
*/
class PlayerIllegalMoveEvent extends PlayerCheatEvent implements Cancellable{
public static $handlerList = null;
/** @var Vector3 */
private $attemptedPosition;

View File

@ -25,6 +25,5 @@ declare(strict_types=1);
namespace pocketmine\event\plugin;
class PluginDisableEvent extends PluginEvent{
public static $handlerList = null;
}

View File

@ -25,6 +25,5 @@ declare(strict_types=1);
namespace pocketmine\event\plugin;
class PluginEnableEvent extends PluginEvent{
public static $handlerList = null;
}

View File

@ -29,9 +29,7 @@ namespace pocketmine\event\plugin;
use pocketmine\event\Event;
use pocketmine\plugin\Plugin;
abstract class PluginEvent extends Event{
/** @var Plugin */
private $plugin;

View File

@ -28,8 +28,6 @@ use pocketmine\network\mcpe\protocol\DataPacket;
use pocketmine\Player;
class DataPacketReceiveEvent extends ServerEvent implements Cancellable{
public static $handlerList = null;
/** @var DataPacket */
private $packet;
/** @var Player */

View File

@ -28,8 +28,6 @@ use pocketmine\network\mcpe\protocol\DataPacket;
use pocketmine\Player;
class DataPacketSendEvent extends ServerEvent implements Cancellable{
public static $handlerList = null;
/** @var DataPacket */
private $packet;
/** @var Player */

View File

@ -31,8 +31,6 @@ use pocketmine\utils\Utils;
* Plugins should free caches or other non-essential data.
*/
class LowMemoryEvent extends ServerEvent{
public static $handlerList = null;
/** @var int */
private $memory;
/** @var int */

View File

@ -29,8 +29,6 @@ use pocketmine\network\SourceInterface;
* Called when a network interface crashes, with relevant crash information.
*/
class NetworkInterfaceCrashEvent extends NetworkInterfaceEvent{
public static $handlerList = null;
/**
* @var \Throwable
*/

View File

@ -29,6 +29,5 @@ use pocketmine\event\Cancellable;
* Called when a network interface is registered into the network, for example the RakLib interface.
*/
class NetworkInterfaceRegisterEvent extends NetworkInterfaceEvent implements Cancellable{
public static $handlerList = null;
}

Some files were not shown because too many files have changed in this diff Show More