Removed pocketmine subdirectory, map PSR-4 style

This commit is contained in:
Dylan K. Taylor
2019-07-30 19:14:57 +01:00
parent 7a77d3dc30
commit 5499ac620c
1044 changed files with 3 additions and 3 deletions

View File

@ -0,0 +1,61 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\block\Block;
use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
/**
* Called when an Entity, excluding players, changes a block directly
*/
class EntityBlockChangeEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
/** @var Block */
private $from;
/** @var Block */
private $to;
public function __construct(Entity $entity, Block $from, Block $to){
$this->entity = $entity;
$this->from = $from;
$this->to = $to;
}
/**
* @return Block
*/
public function getBlock() : Block{
return $this->from;
}
/**
* @return Block
*/
public function getTo() : Block{
return $this->to;
}
}

View File

@ -0,0 +1,49 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\block\Block;
use pocketmine\entity\Entity;
class EntityCombustByBlockEvent extends EntityCombustEvent{
/** @var Block */
protected $combuster;
/**
* @param Block $combuster
* @param Entity $combustee
* @param int $duration
*/
public function __construct(Block $combuster, Entity $combustee, int $duration){
parent::__construct($combustee, $duration);
$this->combuster = $combuster;
}
/**
* @return Block
*/
public function getCombuster() : Block{
return $this->combuster;
}
}

View File

@ -0,0 +1,48 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
class EntityCombustByEntityEvent extends EntityCombustEvent{
/** @var Entity */
protected $combuster;
/**
* @param Entity $combuster
* @param Entity $combustee
* @param int $duration
*/
public function __construct(Entity $combuster, Entity $combustee, int $duration){
parent::__construct($combustee, $duration);
$this->combuster = $combuster;
}
/**
* @return Entity
*/
public function getCombuster() : Entity{
return $this->combuster;
}
}

View File

@ -0,0 +1,55 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
class EntityCombustEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
protected $duration;
/**
* @param Entity $combustee
* @param int $duration
*/
public function __construct(Entity $combustee, int $duration){
$this->entity = $combustee;
$this->duration = $duration;
}
/**
* Returns the duration in seconds the entity will burn for.
* @return int
*/
public function getDuration() : int{
return $this->duration;
}
public function setDuration(int $duration) : void{
$this->duration = $duration;
}
}

View File

@ -0,0 +1,54 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\block\Block;
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
* @param int $cause
* @param float $damage
* @param float[] $modifiers
*/
public function __construct(Block $damager, Entity $entity, int $cause, float $damage, array $modifiers = []){
$this->damager = $damager;
parent::__construct($entity, $cause, $damage, $modifiers);
}
/**
* @return Block
*/
public function getDamager() : Block{
return $this->damager;
}
}

View File

@ -0,0 +1,56 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
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;
/**
* @param Entity $damager
* @param Entity $childEntity
* @param Entity $entity
* @param int $cause
* @param float $damage
* @param float[] $modifiers
*/
public function __construct(Entity $damager, Entity $childEntity, Entity $entity, int $cause, float $damage, array $modifiers = []){
$this->childEntityEid = $childEntity->getId();
parent::__construct($damager, $entity, $cause, $damage, $modifiers);
}
/**
* Returns the entity which caused the damage, or null if the entity has been killed or closed.
*
* @return Entity|null
*/
public function getChild() : ?Entity{
return $this->getEntity()->getWorld()->getServer()->getWorldManager()->findEntity($this->childEntityEid);
}
}

View File

@ -0,0 +1,89 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\effect\VanillaEffects;
use pocketmine\entity\Entity;
use pocketmine\entity\Living;
/**
* Called when an entity takes damage from another entity.
*/
class EntityDamageByEntityEvent extends EntityDamageEvent{
/** @var int */
private $damagerEntityId;
/** @var float */
private $knockBack;
/**
* @param Entity $damager
* @param Entity $entity
* @param int $cause
* @param float $damage
* @param float[] $modifiers
* @param float $knockBack
*/
public function __construct(Entity $damager, Entity $entity, int $cause, float $damage, array $modifiers = [], float $knockBack = 0.4){
$this->damagerEntityId = $damager->getId();
$this->knockBack = $knockBack;
parent::__construct($entity, $cause, $damage, $modifiers);
$this->addAttackerModifiers($damager);
}
protected function addAttackerModifiers(Entity $damager) : void{
if($damager instanceof Living){ //TODO: move this to entity classes
$effects = $damager->getEffects();
if($effects->has(VanillaEffects::STRENGTH())){
$this->setModifier($this->getBaseDamage() * 0.3 * $effects->get(VanillaEffects::STRENGTH())->getEffectLevel(), self::MODIFIER_STRENGTH);
}
if($effects->has(VanillaEffects::WEAKNESS())){
$this->setModifier(-($this->getBaseDamage() * 0.2 * $effects->get(VanillaEffects::WEAKNESS())->getEffectLevel()), self::MODIFIER_WEAKNESS);
}
}
}
/**
* Returns the attacking entity, or null if the attacker has been killed or closed.
*
* @return Entity|null
*/
public function getDamager() : ?Entity{
return $this->getEntity()->getWorld()->getServer()->getWorldManager()->findEntity($this->damagerEntityId);
}
/**
* @return float
*/
public function getKnockBack() : float{
return $this->knockBack;
}
/**
* @param float $knockBack
*/
public function setKnockBack(float $knockBack) : void{
$this->knockBack = $knockBack;
}
}

View File

@ -0,0 +1,227 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
use function array_sum;
/**
* Called when an entity takes damage.
*/
class EntityDamageEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
public const MODIFIER_ARMOR = 1;
public const MODIFIER_STRENGTH = 2;
public const MODIFIER_WEAKNESS = 3;
public const MODIFIER_RESISTANCE = 4;
public const MODIFIER_ABSORPTION = 5;
public const MODIFIER_ARMOR_ENCHANTMENTS = 6;
public const MODIFIER_CRITICAL = 7;
public const MODIFIER_TOTEM = 8;
public const MODIFIER_WEAPON_ENCHANTMENTS = 9;
public const CAUSE_CONTACT = 0;
public const CAUSE_ENTITY_ATTACK = 1;
public const CAUSE_PROJECTILE = 2;
public const CAUSE_SUFFOCATION = 3;
public const CAUSE_FALL = 4;
public const CAUSE_FIRE = 5;
public const CAUSE_FIRE_TICK = 6;
public const CAUSE_LAVA = 7;
public const CAUSE_DROWNING = 8;
public const CAUSE_BLOCK_EXPLOSION = 9;
public const CAUSE_ENTITY_EXPLOSION = 10;
public const CAUSE_VOID = 11;
public const CAUSE_SUICIDE = 12;
public const CAUSE_MAGIC = 13;
public const CAUSE_CUSTOM = 14;
public const CAUSE_STARVATION = 15;
/** @var int */
private $cause;
/** @var float */
private $baseDamage;
/** @var float */
private $originalBase;
/** @var float[] */
private $modifiers;
/** @var float[] */
private $originals;
/** @var int */
private $attackCooldown = 10;
/**
* @param Entity $entity
* @param int $cause
* @param float $damage
* @param float[] $modifiers
*/
public function __construct(Entity $entity, int $cause, float $damage, array $modifiers = []){
$this->entity = $entity;
$this->cause = $cause;
$this->baseDamage = $this->originalBase = $damage;
$this->modifiers = $modifiers;
$this->originals = $this->modifiers;
}
/**
* @return int
*/
public function getCause() : int{
return $this->cause;
}
/**
* Returns the base amount of damage applied, before modifiers.
*
* @return float
*/
public function getBaseDamage() : float{
return $this->baseDamage;
}
/**
* Sets the base amount of damage applied, optionally recalculating modifiers.
*
* TODO: add ability to recalculate modifiers when this is set
*
* @param float $damage
*/
public function setBaseDamage(float $damage) : void{
$this->baseDamage = $damage;
}
/**
* Returns the original base amount of damage applied, before alterations by plugins.
*
* @return float
*/
public function getOriginalBaseDamage() : float{
return $this->originalBase;
}
/**
* @return float[]
*/
public function getOriginalModifiers() : array{
return $this->originals;
}
/**
* @param int $type
*
* @return float
*/
public function getOriginalModifier(int $type) : float{
return $this->originals[$type] ?? 0.0;
}
/**
* @return float[]
*/
public function getModifiers() : array{
return $this->modifiers;
}
/**
* @param int $type
*
* @return float
*/
public function getModifier(int $type) : float{
return $this->modifiers[$type] ?? 0.0;
}
/**
* @param float $damage
* @param int $type
*/
public function setModifier(float $damage, int $type) : void{
$this->modifiers[$type] = $damage;
}
/**
* @param int $type
*
* @return bool
*/
public function isApplicable(int $type) : bool{
return isset($this->modifiers[$type]);
}
/**
* @return float
*/
public function getFinalDamage() : float{
return $this->baseDamage + array_sum($this->modifiers);
}
/**
* Returns whether an entity can use armour points to reduce this type of damage.
* @return bool
*/
public function canBeReducedByArmor() : bool{
switch($this->cause){
case self::CAUSE_FIRE_TICK:
case self::CAUSE_SUFFOCATION:
case self::CAUSE_DROWNING:
case self::CAUSE_STARVATION:
case self::CAUSE_FALL:
case self::CAUSE_VOID:
case self::CAUSE_MAGIC:
case self::CAUSE_SUICIDE:
return false;
}
return true;
}
/**
* Returns the cooldown in ticks before the target entity can be attacked again.
*
* @return int
*/
public function getAttackCooldown() : int{
return $this->attackCooldown;
}
/**
* Sets the cooldown in ticks before the target entity can be attacked again.
*
* NOTE: This value is not used in non-Living entities
*
* @param int $attackCooldown
*/
public function setAttackCooldown(int $attackCooldown) : void{
$this->attackCooldown = $attackCooldown;
}
}

View File

@ -0,0 +1,86 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\Living;
use pocketmine\item\Item;
class EntityDeathEvent extends EntityEvent{
/** @var Item[] */
private $drops = [];
/** @var int */
private $xp;
/**
* @param Living $entity
* @param Item[] $drops
* @param int $xp
*/
public function __construct(Living $entity, array $drops = [], int $xp = 0){
$this->entity = $entity;
$this->drops = $drops;
$this->xp = $xp;
}
/**
* @return Living
*/
public function getEntity(){
return $this->entity;
}
/**
* @return Item[]
*/
public function getDrops() : array{
return $this->drops;
}
/**
* @param Item[] $drops
*/
public function setDrops(array $drops) : void{
$this->drops = $drops;
}
/**
* Returns how much experience is dropped due to this entity's death.
* @return int
*/
public function getXpDropAmount() : int{
return $this->xp;
}
/**
* @param int $xp
*
* @throws \InvalidArgumentException
*/
public function setXpDropAmount(int $xp) : void{
if($xp < 0){
throw new \InvalidArgumentException("XP drop amount must not be negative");
}
$this->xp = $xp;
}
}

View File

@ -0,0 +1,39 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
/**
* Called when a entity is despawned
*/
class EntityDespawnEvent extends EntityEvent{
/**
* @param Entity $entity
*/
public function __construct(Entity $entity){
$this->entity = $entity;
}
}

View File

@ -0,0 +1,68 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\effect\EffectInstance;
use pocketmine\entity\Entity;
/**
* Called when an effect is added to an Entity.
*/
class EntityEffectAddEvent extends EntityEffectEvent{
/** @var EffectInstance|null */
private $oldEffect;
/**
* @param Entity $entity
* @param EffectInstance $effect
* @param EffectInstance $oldEffect
*/
public function __construct(Entity $entity, EffectInstance $effect, ?EffectInstance $oldEffect = null){
parent::__construct($entity, $effect);
$this->oldEffect = $oldEffect;
}
/**
* Returns whether the effect addition will replace an existing effect already applied to the entity.
*
* @return bool
*/
public function willModify() : bool{
return $this->hasOldEffect();
}
/**
* @return bool
*/
public function hasOldEffect() : bool{
return $this->oldEffect instanceof EffectInstance;
}
/**
* @return EffectInstance|null
*/
public function getOldEffect() : ?EffectInstance{
return $this->oldEffect;
}
}

View File

@ -0,0 +1,45 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\effect\EffectInstance;
use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
class EntityEffectEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
/** @var EffectInstance */
private $effect;
public function __construct(Entity $entity, EffectInstance $effect){
$this->entity = $entity;
$this->effect = $effect;
}
public function getEffect() : EffectInstance{
return $this->effect;
}
}

View File

@ -0,0 +1,36 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
/**
* Called when an effect is removed from an entity.
*/
class EntityEffectRemoveEvent extends EntityEffectEvent{
public function setCancelled(bool $value = true) : void{
if($this->getEffect()->getDuration() <= 0){
throw new \InvalidStateException("Removal of expired effects cannot be cancelled");
}
parent::setCancelled($value);
}
}

View File

@ -0,0 +1,42 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
/**
* Entity related Events, like spawn, inventory, attack...
*/
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
use pocketmine\event\Event;
abstract class EntityEvent extends Event{
/** @var Entity */
protected $entity;
/**
* @return Entity
*/
public function getEntity(){
return $this->entity;
}
}

View File

@ -0,0 +1,96 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\block\Block;
use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
use pocketmine\world\Position;
/**
* Called when a entity explodes
*/
class EntityExplodeEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
/** @var Position */
protected $position;
/**
* @var Block[]
*/
protected $blocks;
/** @var float */
protected $yield;
/**
* @param Entity $entity
* @param Position $position
* @param Block[] $blocks
* @param float $yield
*/
public function __construct(Entity $entity, Position $position, array $blocks, float $yield){
$this->entity = $entity;
$this->position = $position;
$this->blocks = $blocks;
$this->yield = $yield;
}
/**
* @return Position
*/
public function getPosition() : Position{
return $this->position;
}
/**
* @return Block[]
*/
public function getBlockList() : array{
return $this->blocks;
}
/**
* @param Block[] $blocks
*/
public function setBlockList(array $blocks) : void{
$this->blocks = $blocks;
}
/**
* @return float
*/
public function getYield() : float{
return $this->yield;
}
/**
* @param float $yield
*/
public function setYield(float $yield) : void{
$this->yield = $yield;
}
}

View File

@ -0,0 +1,48 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
use pocketmine\math\Vector3;
class EntityMotionEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
/** @var Vector3 */
private $mot;
public function __construct(Entity $entity, Vector3 $mot){
$this->entity = $entity;
$this->mot = $mot;
}
/**
* @return Vector3
*/
public function getVector() : Vector3{
return $this->mot;
}
}

View File

@ -0,0 +1,77 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
class EntityRegainHealthEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
public const CAUSE_REGEN = 0;
public const CAUSE_EATING = 1;
public const CAUSE_MAGIC = 2;
public const CAUSE_CUSTOM = 3;
public const CAUSE_SATURATION = 4;
/** @var float */
private $amount;
/** @var int */
private $reason;
/**
* @param Entity $entity
* @param float $amount
* @param int $regainReason
*/
public function __construct(Entity $entity, float $amount, int $regainReason){
$this->entity = $entity;
$this->amount = $amount;
$this->reason = $regainReason;
}
/**
* @return float
*/
public function getAmount() : float{
return $this->amount;
}
/**
* @param float $amount
*/
public function setAmount(float $amount) : void{
$this->amount = $amount;
}
/**
* Returns one of the CAUSE_* constants to indicate why this regeneration occurred.
* @return int
*/
public function getRegainReason() : int{
return $this->reason;
}
}

View File

@ -0,0 +1,107 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
use pocketmine\entity\Living;
use pocketmine\entity\projectile\Projectile;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
use pocketmine\item\Item;
use function count;
class EntityShootBowEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
/** @var Item */
private $bow;
/** @var Projectile */
private $projectile;
/** @var float */
private $force;
/**
* @param Living $shooter
* @param Item $bow
* @param Projectile $projectile
* @param float $force
*/
public function __construct(Living $shooter, Item $bow, Projectile $projectile, float $force){
$this->entity = $shooter;
$this->bow = $bow;
$this->projectile = $projectile;
$this->force = $force;
}
/**
* @return Living
*/
public function getEntity(){
return $this->entity;
}
/**
* @return Item
*/
public function getBow() : Item{
return $this->bow;
}
/**
* Returns the entity considered as the projectile in this event.
*
* NOTE: This might not return a Projectile if a plugin modified the target entity.
*
* @return Entity
*/
public function getProjectile() : Entity{
return $this->projectile;
}
/**
* @param Entity $projectile
*/
public function setProjectile(Entity $projectile) : void{
if($projectile !== $this->projectile){
if(count($this->projectile->getViewers()) === 0){
$this->projectile->close();
}
$this->projectile = $projectile;
}
}
/**
* @return float
*/
public function getForce() : float{
return $this->force;
}
/**
* @param float $force
*/
public function setForce(float $force) : void{
$this->force = $force;
}
}

View File

@ -0,0 +1,39 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
/**
* Called when a entity is spawned
*/
class EntitySpawnEvent extends EntityEvent{
/**
* @param Entity $entity
*/
public function __construct(Entity $entity){
$this->entity = $entity;
}
}

View File

@ -0,0 +1,65 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
use pocketmine\world\Position;
class EntityTeleportEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
/** @var Position */
private $from;
/** @var Position */
private $to;
public function __construct(Entity $entity, Position $from, Position $to){
$this->entity = $entity;
$this->from = $from;
$this->to = $to;
}
/**
* @return Position
*/
public function getFrom() : Position{
return $this->from;
}
/**
* @return Position
*/
public function getTo() : Position{
return $this->to;
}
/**
* @param Position $to
*/
public function setTo(Position $to) : void{
$this->to = $to;
}
}

View File

@ -0,0 +1,75 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
/**
* Called when a entity decides to explode
*/
class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
/** @var float */
protected $force;
/** @var bool */
private $blockBreaking;
/**
* @param Entity $entity
* @param float $force
*/
public function __construct(Entity $entity, float $force){
$this->entity = $entity;
$this->force = $force;
$this->blockBreaking = true;
}
/**
* @return float
*/
public function getForce() : float{
return $this->force;
}
public function setForce(float $force) : void{
$this->force = $force;
}
/**
* @return bool
*/
public function isBlockBreaking() : bool{
return $this->blockBreaking;
}
/**
* @param bool $affectsBlocks
*/
public function setBlockBreaking(bool $affectsBlocks) : void{
$this->blockBreaking = $affectsBlocks;
}
}

View File

@ -0,0 +1,46 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\object\ItemEntity;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
class ItemDespawnEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
/**
* @param ItemEntity $item
*/
public function __construct(ItemEntity $item){
$this->entity = $item;
}
/**
* @return ItemEntity
*/
public function getEntity(){
return $this->entity;
}
}

View File

@ -0,0 +1,44 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\object\ItemEntity;
class ItemSpawnEvent extends EntityEvent{
/**
* @param ItemEntity $item
*/
public function __construct(ItemEntity $item){
$this->entity = $item;
}
/**
* @return ItemEntity
*/
public function getEntity(){
return $this->entity;
}
}

View File

@ -0,0 +1,48 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\block\Block;
use pocketmine\entity\projectile\Projectile;
use pocketmine\math\RayTraceResult;
class ProjectileHitBlockEvent extends ProjectileHitEvent{
/** @var Block */
private $blockHit;
public function __construct(Projectile $entity, RayTraceResult $rayTraceResult, Block $blockHit){
parent::__construct($entity, $rayTraceResult);
$this->blockHit = $blockHit;
}
/**
* Returns the Block struck by the projectile.
* Hint: to get the block face hit, look at the RayTraceResult.
*
* @return Block
*/
public function getBlockHit() : Block{
return $this->blockHit;
}
}

View File

@ -0,0 +1,47 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\Entity;
use pocketmine\entity\projectile\Projectile;
use pocketmine\math\RayTraceResult;
class ProjectileHitEntityEvent extends ProjectileHitEvent{
/** @var Entity */
private $entityHit;
public function __construct(Projectile $entity, RayTraceResult $rayTraceResult, Entity $entityHit){
parent::__construct($entity, $rayTraceResult);
$this->entityHit = $entityHit;
}
/**
* Returns the Entity struck by the projectile.
*
* @return Entity
*/
public function getEntityHit() : Entity{
return $this->entityHit;
}
}

View File

@ -0,0 +1,61 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\projectile\Projectile;
use pocketmine\math\RayTraceResult;
/**
* @allowHandle
*/
abstract class ProjectileHitEvent extends EntityEvent{
/** @var RayTraceResult */
private $rayTraceResult;
/**
* @param Projectile $entity
* @param RayTraceResult $rayTraceResult
*/
public function __construct(Projectile $entity, RayTraceResult $rayTraceResult){
$this->entity = $entity;
$this->rayTraceResult = $rayTraceResult;
}
/**
* @return Projectile
*/
public function getEntity(){
return $this->entity;
}
/**
* Returns a RayTraceResult object containing information such as the exact position struck, the AABB it hit, and
* the face of the AABB that it hit.
*
* @return RayTraceResult
*/
public function getRayTraceResult() : RayTraceResult{
return $this->rayTraceResult;
}
}

View File

@ -0,0 +1,46 @@
<?php
/*
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
declare(strict_types=1);
namespace pocketmine\event\entity;
use pocketmine\entity\projectile\Projectile;
use pocketmine\event\Cancellable;
use pocketmine\event\CancellableTrait;
class ProjectileLaunchEvent extends EntityEvent implements Cancellable{
use CancellableTrait;
/**
* @param Projectile $entity
*/
public function __construct(Projectile $entity){
$this->entity = $entity;
}
/**
* @return Projectile
*/
public function getEntity(){
return $this->entity;
}
}