mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Added Event allocation pool, updated SPL with Class::onClassLoaded()
This commit is contained in:
parent
144a871c07
commit
350cee3d41
@ -652,7 +652,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
$pos = $this->level->getSafeSpawn($this);
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $pos));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerRespawnEvent::createEvent($this, $pos));
|
||||
|
||||
$this->teleport($ev->getRespawnPosition());
|
||||
|
||||
@ -660,7 +660,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->inventory->sendContents($this);
|
||||
$this->inventory->sendArmorContents($this);
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerJoinEvent($this, TextFormat::YELLOW . $this->getName() . " joined the game"));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerJoinEvent::createEvent($this, TextFormat::YELLOW . $this->getName() . " joined the game"));
|
||||
if(strlen(trim($ev->getJoinMessage())) > 0){
|
||||
$this->server->broadcastMessage($ev->getJoinMessage());
|
||||
}
|
||||
@ -745,7 +745,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
if($this->connected === false){
|
||||
return false;
|
||||
}
|
||||
$this->server->getPluginManager()->callEvent($ev = new DataPacketSendEvent($this, $packet));
|
||||
$this->server->getPluginManager()->callEvent($ev = DataPacketSendEvent::createEvent($this, $packet));
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
@ -771,7 +771,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
if($this->connected === false){
|
||||
return false;
|
||||
}
|
||||
$this->server->getPluginManager()->callEvent($ev = new DataPacketSendEvent($this, $packet));
|
||||
$this->server->getPluginManager()->callEvent($ev = DataPacketSendEvent::createEvent($this, $packet));
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
@ -803,7 +803,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
}
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerBedEnterEvent($this, $this->level->getBlock($pos)));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerBedEnterEvent::createEvent($this, $this->level->getBlock($pos)));
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
@ -842,7 +842,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
public function stopSleep(){
|
||||
if($this->sleeping instanceof Vector3){
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerBedLeaveEvent($this, $this->level->getBlock($this->sleeping)));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerBedLeaveEvent::createEvent($this, $this->level->getBlock($this->sleeping)));
|
||||
|
||||
$this->sleeping = null;
|
||||
|
||||
@ -892,7 +892,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerAchievementAwardedEvent($this, $achievementId));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerAchievementAwardedEvent::createEvent($this, $achievementId));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->achievements[$achievementId] = true;
|
||||
Achievement::broadcast($this, $achievementId);
|
||||
@ -926,7 +926,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerGameModeChangeEvent($this, (int) $gm));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerGameModeChangeEvent::createEvent($this, (int) $gm));
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
@ -1116,7 +1116,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->lastYaw = $to->yaw;
|
||||
$this->lastPitch = $to->pitch;
|
||||
|
||||
$ev = new PlayerMoveEvent($this, $from, $to);
|
||||
$ev = PlayerMoveEvent::createEvent($this, $from, $to);
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev);
|
||||
|
||||
@ -1200,7 +1200,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new InventoryPickupItemEvent($this->inventory, $item));
|
||||
$this->server->getPluginManager()->callEvent($ev = InventoryPickupItemEvent::createEvent($this->inventory, $item));
|
||||
if($ev->isCancelled()){
|
||||
continue;
|
||||
}
|
||||
@ -1225,7 +1225,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new InventoryPickupItemEvent($this->inventory, $item));
|
||||
$this->server->getPluginManager()->callEvent($ev = InventoryPickupItemEvent::createEvent($this->inventory, $item));
|
||||
if($ev->isCancelled()){
|
||||
continue;
|
||||
}
|
||||
@ -1282,7 +1282,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
|
||||
$this->server->getPluginManager()->callEvent($ev = DataPacketReceiveEvent::createEvent($this, $packet));
|
||||
if($ev->isCancelled()){
|
||||
return;
|
||||
}
|
||||
@ -1324,7 +1324,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerPreLoginEvent($this, "Plugin reason"));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerPreLoginEvent::createEvent($this, "Plugin reason"));
|
||||
if($ev->isCancelled()){
|
||||
$this->close("", $ev->getKickMessage());
|
||||
|
||||
@ -1399,7 +1399,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
parent::__construct($this->level->getChunk($nbt["Pos"][0] >> 4, $nbt["Pos"][2] >> 4, true), $nbt);
|
||||
$this->loggedIn = true;
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerLoginEvent($this, "Plugin reason"));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerLoginEvent::createEvent($this, "Plugin reason"));
|
||||
if($ev->isCancelled()){
|
||||
$this->close(TextFormat::YELLOW . $this->username . " has left the game", $ev->getKickMessage());
|
||||
|
||||
@ -1673,7 +1673,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
]);
|
||||
|
||||
$f = 1.5;
|
||||
$ev = new EntityShootBowEvent($this, $bow, new Arrow($this->chunk, $nbt, $this), $f);
|
||||
$ev = EntityShootBowEvent::createEvent($this, $bow, new Arrow($this->chunk, $nbt, $this), $f);
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev);
|
||||
|
||||
@ -1690,7 +1690,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
}
|
||||
}
|
||||
if($ev->getProjectile() instanceof Projectile){
|
||||
$this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
|
||||
$this->server->getPluginManager()->callEvent($projectileEv = ProjectileLaunchEvent::createEvent($ev->getProjectile()));
|
||||
if($projectileEv->isCancelled()){
|
||||
$ev->getProjectile()->kill();
|
||||
}else{
|
||||
@ -1852,7 +1852,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$damage[EntityDamageEvent::MODIFIER_ARMOR] = -intval($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
|
||||
}
|
||||
|
||||
$ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage);
|
||||
$ev = EntityDamageByEntityEvent::createEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage);
|
||||
if($cancelled){
|
||||
$ev->setCancelled();
|
||||
}
|
||||
@ -1882,7 +1882,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
break;
|
||||
}
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerAnimationEvent::createEvent($this, $packet->action));
|
||||
if($ev->isCancelled()){
|
||||
break;
|
||||
}
|
||||
@ -1899,7 +1899,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
$this->craftingType = 0;
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->getSpawn()));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerRespawnEvent::createEvent($this, $this->getSpawn()));
|
||||
|
||||
$this->teleport($ev->getRespawnPosition());
|
||||
$this->fireTicks = 0;
|
||||
@ -1955,7 +1955,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
];
|
||||
$slot = $this->inventory->getItemInHand();
|
||||
if($this->getHealth() < 20 and isset($items[$slot->getID()])){
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $slot));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerItemConsumeEvent::createEvent($this, $slot));
|
||||
if($ev->isCancelled()){
|
||||
$this->inventory->sendContents($this);
|
||||
break;
|
||||
@ -1969,7 +1969,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
Server::broadcastPacket($this->getViewers(), $pk);
|
||||
|
||||
$amount = $items[$slot->getID()];
|
||||
$this->server->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($this, $amount, EntityRegainHealthEvent::CAUSE_EATING));
|
||||
$this->server->getPluginManager()->callEvent($ev = EntityRegainHealthEvent::createEvent($this, $amount, EntityRegainHealthEvent::CAUSE_EATING));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->heal($ev->getAmount(), $ev);
|
||||
}
|
||||
@ -1989,7 +1989,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
}
|
||||
$packet->eid = $this->id;
|
||||
$item = $this->inventory->getItemInHand();
|
||||
$ev = new PlayerDropItemEvent($this, $item);
|
||||
$ev = PlayerDropItemEvent::createEvent($this, $item);
|
||||
$this->server->getPluginManager()->callEvent($ev);
|
||||
if($ev->isCancelled()){
|
||||
$this->inventory->sendContents($this);
|
||||
@ -2014,7 +2014,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$packet->message = TextFormat::clean($packet->message);
|
||||
if(trim($packet->message) != "" and strlen($packet->message) <= 255){
|
||||
$message = $packet->message;
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerCommandPreprocessEvent($this, $message));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerCommandPreprocessEvent::createEvent($this, $message));
|
||||
if($ev->isCancelled()){
|
||||
break;
|
||||
}
|
||||
@ -2023,7 +2023,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1));
|
||||
Timings::$playerCommandTimer->stopTiming();
|
||||
}else{
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerChatEvent($this, $ev->getMessage()));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerChatEvent::createEvent($this, $ev->getMessage()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->server->broadcastMessage(sprintf($ev->getFormat(), $ev->getPlayer()->getDisplayName(), $ev->getMessage()), $ev->getRecipients());
|
||||
}
|
||||
@ -2037,7 +2037,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
$this->craftingType = 0;
|
||||
$this->currentTransaction = null;
|
||||
if(isset($this->windowIndex[$packet->windowid])){
|
||||
$this->server->getPluginManager()->callEvent(new InventoryCloseEvent($this->windowIndex[$packet->windowid], $this));
|
||||
$this->server->getPluginManager()->callEvent(InventoryCloseEvent::createEvent($this->windowIndex[$packet->windowid], $this));
|
||||
$this->removeWindow($this->windowIndex[$packet->windowid]);
|
||||
}else{
|
||||
unset($this->windowIndex[$packet->windowid]);
|
||||
@ -2192,7 +2192,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
if($nbt["id"] !== Tile::SIGN){
|
||||
$t->spawnTo($this);
|
||||
}else{
|
||||
$ev = new SignChangeEvent($t->getBlock(), $this, [
|
||||
$ev = SignChangeEvent::createEvent($t->getBlock(), $this, [
|
||||
$nbt["Text1"], $nbt["Text2"], $nbt["Text3"], $nbt["Text4"]
|
||||
]);
|
||||
|
||||
@ -2223,7 +2223,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
* @return bool
|
||||
*/
|
||||
public function kick($reason = ""){
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerKickEvent($this, $reason, TextFormat::YELLOW . $this->username . " has left the game"));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerKickEvent::createEvent($this, $reason, TextFormat::YELLOW . $this->username . " has left the game"));
|
||||
if(!$ev->isCancelled()){
|
||||
$message = "Kicked by admin." . ($reason !== "" ? " Reason: " . $reason : "");
|
||||
$this->sendMessage($message);
|
||||
@ -2269,7 +2269,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
if($this->connected and !$this->closed){
|
||||
$this->connected = false;
|
||||
if($this->username != ""){
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerQuitEvent($this, $message));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerQuitEvent::createEvent($this, $message));
|
||||
if($this->server->getAutoSave() and $this->loggedIn === true){
|
||||
$this->save();
|
||||
}
|
||||
@ -2439,7 +2439,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
|
||||
|
||||
Entity::kill();
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new PlayerDeathEvent($this, $this->getDrops(), $message));
|
||||
$this->server->getPluginManager()->callEvent($ev = PlayerDeathEvent::createEvent($this, $this->getDrops(), $message));
|
||||
|
||||
if(!$ev->getKeepInventory()){
|
||||
foreach($ev->getDrops() as $item){
|
||||
|
@ -31,6 +31,7 @@ use pocketmine\command\CommandSender;
|
||||
use pocketmine\command\ConsoleCommandSender;
|
||||
use pocketmine\command\PluginIdentifiableCommand;
|
||||
use pocketmine\command\SimpleCommandMap;
|
||||
use pocketmine\event\Event;
|
||||
use pocketmine\event\HandlerList;
|
||||
use pocketmine\event\level\LevelInitEvent;
|
||||
use pocketmine\event\level\LevelLoadEvent;
|
||||
@ -974,7 +975,7 @@ class Server{
|
||||
|
||||
$level->initLevel();
|
||||
|
||||
$this->getPluginManager()->callEvent(new LevelLoadEvent($level));
|
||||
$this->getPluginManager()->callEvent(LevelLoadEvent::createEvent($level));
|
||||
|
||||
/*foreach($entities->getAll() as $entity){
|
||||
if(!isset($entity["id"])){
|
||||
@ -1109,9 +1110,9 @@ class Server{
|
||||
|
||||
$level->initLevel();
|
||||
|
||||
$this->getPluginManager()->callEvent(new LevelInitEvent($level));
|
||||
$this->getPluginManager()->callEvent(LevelInitEvent::createEvent($level));
|
||||
|
||||
$this->getPluginManager()->callEvent(new LevelLoadEvent($level));
|
||||
$this->getPluginManager()->callEvent(LevelLoadEvent::createEvent($level));
|
||||
|
||||
$this->getLogger()->notice("Spawn terrain for level \"$name\" is being generated in the background");
|
||||
|
||||
@ -1743,7 +1744,7 @@ class Server{
|
||||
public function checkConsole(){
|
||||
Timings::$serverCommandTimer->startTiming();
|
||||
if(($line = $this->console->getLine()) !== null){
|
||||
$this->pluginManager->callEvent($ev = new ServerCommandEvent($this->consoleSender, $line));
|
||||
$this->pluginManager->callEvent($ev = ServerCommandEvent::createEvent($this->consoleSender, $line));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->dispatchCommand($ev->getSender(), $ev->getCommand());
|
||||
}
|
||||
@ -2119,6 +2120,9 @@ class Server{
|
||||
Vector3::clearVectorList();
|
||||
Position::clearPositionList();
|
||||
AxisAlignedBB::clearBoundingBoxPool();
|
||||
if(($this->tickCounter % 4) === 0){
|
||||
Event::clearAllPools();
|
||||
}
|
||||
|
||||
Timings::$serverTickTimer->stopTiming();
|
||||
|
||||
|
@ -55,7 +55,7 @@ class Cactus extends Transparent{
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
|
||||
$ev = EntityDamageByBlockEvent::createEvent($this, $entity, EntityDamageEvent::CAUSE_CONTACT, 1);
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev);
|
||||
if(!$ev->isCancelled()){
|
||||
$entity->attack($ev->getFinalDamage(), $ev);
|
||||
@ -81,7 +81,7 @@ class Cactus extends Transparent{
|
||||
for($y = 1; $y < 3; ++$y){
|
||||
$b = $this->getLevel()->getBlock(Vector3::createVector($this->x, $this->y + $y, $this->z));
|
||||
if($b->getID() === self::AIR){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Cactus()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($b, new Cactus()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ class Cake extends Transparent{
|
||||
public function onActivate(Item $item, Player $player = null){
|
||||
if($player instanceof Player and $player->getHealth() < 20){
|
||||
++$this->meta;
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityRegainHealthEvent($player, 3, EntityRegainHealthEvent::CAUSE_EATING));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = EntityRegainHealthEvent::createEvent($player, 3, EntityRegainHealthEvent::CAUSE_EATING));
|
||||
if(!$ev->isCancelled()){
|
||||
$player->heal($ev->getAmount(), $ev);
|
||||
}
|
||||
|
@ -57,7 +57,7 @@ abstract class Crops extends Flowable{
|
||||
$block->meta = 7;
|
||||
}
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($this, $block));
|
||||
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($this, $ev->getNewState(), true, true);
|
||||
@ -82,7 +82,7 @@ abstract class Crops extends Flowable{
|
||||
if($this->meta < 0x07){
|
||||
$block = clone $this;
|
||||
++$block->meta;
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($this, $block));
|
||||
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($this, $ev->getNewState(), true, true);
|
||||
|
@ -46,13 +46,13 @@ class Fire extends Flowable{
|
||||
}
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
|
||||
$ev = EntityDamageByBlockEvent::createEvent($this, $entity, EntityDamageEvent::CAUSE_FIRE, 1);
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev);
|
||||
if(!$ev->isCancelled()){
|
||||
$entity->attack($ev->getFinalDamage(), $ev);
|
||||
}
|
||||
|
||||
$ev = new EntityCombustByBlockEvent($this, $entity, 8);
|
||||
$ev = EntityCombustByBlockEvent::createEvent($this, $entity, 8);
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev);
|
||||
if(!$ev->isCancelled()){
|
||||
$entity->setOnFire($ev->getDuration());
|
||||
|
@ -58,7 +58,7 @@ class Grass extends Solid{
|
||||
if($block === Block::DIRT){
|
||||
$block = Block::get($block, $this->getLevel()->getBlockDataAt($x, $y, $z), Position::createPosition($x, $y, $z, $this->getLevel()));
|
||||
if($block->getSide(1) instanceof Transparent){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Grass()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockSpreadEvent::createEvent($block, $this, new Grass()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($block, $ev->getNewState());
|
||||
}
|
||||
|
@ -38,13 +38,13 @@ class Lava extends Liquid{
|
||||
|
||||
public function onEntityCollide(Entity $entity){
|
||||
$entity->fallDistance *= 0.5;
|
||||
$ev = new EntityDamageByBlockEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
|
||||
$ev = EntityDamageByBlockEvent::createEvent($this, $entity, EntityDamageEvent::CAUSE_LAVA, 4);
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev);
|
||||
if(!$ev->isCancelled()){
|
||||
$entity->attack($ev->getFinalDamage(), $ev);
|
||||
}
|
||||
|
||||
$ev = new EntityCombustByBlockEvent($this, $entity, 15);
|
||||
$ev = EntityCombustByBlockEvent::createEvent($this, $entity, 15);
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev);
|
||||
if(!$ev->isCancelled()){
|
||||
$entity->setOnFire($ev->getDuration());
|
||||
|
@ -124,7 +124,7 @@ class Leaves extends Transparent{
|
||||
$visited = [];
|
||||
$check = 0;
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new LeavesDecayEvent($this));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = LeavesDecayEvent::createEvent($this));
|
||||
|
||||
if($ev->isCancelled() or $this->findLog($this, $visited, 0, $check) === true){
|
||||
$this->getLevel()->setBlock($this, $this, false, false);
|
||||
|
@ -116,7 +116,7 @@ class Leaves2 extends Leaves{
|
||||
$visited = [];
|
||||
$check = 0;
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new LeavesDecayEvent($this));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = LeavesDecayEvent::createEvent($this));
|
||||
|
||||
if($ev->isCancelled() or $this->findLog($this, $visited, 0, $check) === true){
|
||||
$this->getLevel()->setBlock($this, $this, false, false);
|
||||
|
@ -42,7 +42,7 @@ class MelonStem extends Crops{
|
||||
if($this->meta < 0x07){
|
||||
$block = clone $this;
|
||||
++$block->meta;
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($this, $block));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($this, $ev->getNewState(), true);
|
||||
}
|
||||
@ -58,7 +58,7 @@ class MelonStem extends Crops{
|
||||
$side = $this->getSide(mt_rand(2, 5));
|
||||
$d = $side->getSide(0);
|
||||
if($side->getID() === self::AIR and ($d->getID() === self::FARMLAND or $d->getID() === self::GRASS or $d->getID() === self::DIRT)){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, new Melon()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($side, new Melon()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($side, $ev->getNewState(), true);
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class Mycelium extends Solid{
|
||||
if($block === Block::DIRT){
|
||||
$block = Block::get($block, $this->getLevel()->getBlockDataAt($x, $y, $z), Position::createPosition($x, $y, $z, $this->getLevel()));
|
||||
if($block->getSide(1) instanceof Transparent){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockSpreadEvent($block, $this, new Mycelium()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockSpreadEvent::createEvent($block, $this, new Mycelium()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($block, $ev->getNewState());
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ class PumpkinStem extends Crops{
|
||||
if($this->meta < 0x07){
|
||||
$block = clone $this;
|
||||
++$block->meta;
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($this, $block));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($this, $block));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($this, $ev->getNewState(), true);
|
||||
}
|
||||
@ -58,7 +58,7 @@ class PumpkinStem extends Crops{
|
||||
$side = $this->getSide(mt_rand(2, 5));
|
||||
$d = $side->getSide(0);
|
||||
if($side->getID() === self::AIR and ($d->getID() === self::FARMLAND or $d->getID() === self::GRASS or $d->getID() === self::DIRT)){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($side, new Pumpkin()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($side, new Pumpkin()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($side, $ev->getNewState(), true);
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ class Sugarcane extends Flowable{
|
||||
for($y = 1; $y < 3; ++$y){
|
||||
$b = $this->getLevel()->getBlock(Vector3::createVector($this->x, $this->y + $y, $this->z));
|
||||
if($b->getID() === self::AIR){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new BlockGrowEvent($b, new Sugarcane()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = BlockGrowEvent::createEvent($b, new Sugarcane()));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($b, $ev->getNewState(), true);
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ class KillCommand extends VanillaCommand{
|
||||
}
|
||||
|
||||
if($sender instanceof Player){
|
||||
$sender->getServer()->getPluginManager()->callEvent($ev = new EntityDamageEvent($sender, EntityDamageEvent::CAUSE_SUICIDE, 1000));
|
||||
$sender->getServer()->getPluginManager()->callEvent($ev = EntityDamageEvent::createEvent($sender, EntityDamageEvent::CAUSE_SUICIDE, 1000));
|
||||
|
||||
if($ev->isCancelled()){
|
||||
return true;
|
||||
|
@ -123,13 +123,13 @@ class Arrow extends Projectile{
|
||||
if($movingObjectPosition !== null){
|
||||
if($movingObjectPosition->entityHit !== null){
|
||||
|
||||
$this->server->getPluginManager()->callEvent(new ProjectileHitEvent($this));
|
||||
$this->server->getPluginManager()->callEvent(ProjectileHitEvent::createEvent($this));
|
||||
|
||||
$motion = sqrt($this->motionX ** 2 + $this->motionY ** 2 + $this->motionZ ** 2);
|
||||
$damage = ceil($motion * $this->damage);
|
||||
|
||||
|
||||
$ev = new EntityDamageByEntityEvent($this->shootingEntity === null ? $this : $this->shootingEntity, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
|
||||
$ev = EntityDamageByEntityEvent::createEvent($this->shootingEntity === null ? $this : $this->shootingEntity, $movingObjectPosition->entityHit, EntityDamageEvent::CAUSE_PROJECTILE, $damage);
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev);
|
||||
|
||||
@ -138,7 +138,7 @@ class Arrow extends Projectile{
|
||||
}
|
||||
|
||||
if($this->fireTicks > 0){
|
||||
$ev = new EntityCombustByEntityEvent($this, $movingObjectPosition->entityHit, 5);
|
||||
$ev = EntityCombustByEntityEvent::createEvent($this, $movingObjectPosition->entityHit, 5);
|
||||
$this->server->getPluginManager()->callEvent($ev);
|
||||
if(!$ev->isCancelled()){
|
||||
$movingObjectPosition->entityHit->setOnFire($ev->getDuration());
|
||||
@ -157,7 +157,7 @@ class Arrow extends Projectile{
|
||||
$this->motionY = 0;
|
||||
$this->motionZ = 0;
|
||||
|
||||
$this->server->getPluginManager()->callEvent(new ProjectileHitEvent($this));
|
||||
$this->server->getPluginManager()->callEvent(ProjectileHitEvent::createEvent($this));
|
||||
}
|
||||
|
||||
if(!$this->onGround or $this->motionX != 0 or $this->motionY != 0 or $this->motionZ != 0){
|
||||
|
@ -70,7 +70,7 @@ class DroppedItem extends Entity{
|
||||
$this->item = Item::get($this->namedtag->Item["id"], $this->namedtag->Item["Damage"], $this->namedtag->Item["Count"]);
|
||||
|
||||
|
||||
$this->server->getPluginManager()->callEvent(new ItemSpawnEvent($this));
|
||||
$this->server->getPluginManager()->callEvent(ItemSpawnEvent::createEvent($this));
|
||||
}
|
||||
|
||||
public function onUpdate($currentTick){
|
||||
@ -113,7 +113,7 @@ class DroppedItem extends Entity{
|
||||
}
|
||||
|
||||
if($this->age > 6000){
|
||||
$this->server->getPluginManager()->callEvent($ev = new ItemDespawnEvent($this));
|
||||
$this->server->getPluginManager()->callEvent($ev = ItemDespawnEvent::createEvent($this));
|
||||
if($ev->isCancelled()){
|
||||
$this->age = 0;
|
||||
}else{
|
||||
|
@ -213,7 +213,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
$this->level->addEntity($this);
|
||||
$this->initEntity();
|
||||
$this->lastUpdate = $this->server->getTick();
|
||||
$this->server->getPluginManager()->callEvent(new EntitySpawnEvent($this));
|
||||
$this->server->getPluginManager()->callEvent(EntitySpawnEvent::createEvent($this));
|
||||
|
||||
$this->scheduleUpdate();
|
||||
|
||||
@ -483,7 +483,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
$this->checkBlockCollision();
|
||||
|
||||
if($this->y < 0 and $this->dead !== true){
|
||||
$this->server->getPluginManager()->callEvent($ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_VOID, 10));
|
||||
$this->server->getPluginManager()->callEvent($ev = EntityDamageEvent::createEvent($this, EntityDamageEvent::CAUSE_VOID, 10));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->attack($ev->getFinalDamage(), $ev);
|
||||
}
|
||||
@ -498,7 +498,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
}
|
||||
}else{
|
||||
if(($this->fireTicks % 20) === 0 or $tickDiff > 20){
|
||||
$ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FIRE_TICK, 1);
|
||||
$ev = EntityDamageEvent::createEvent($this, EntityDamageEvent::CAUSE_FIRE_TICK, 1);
|
||||
$this->server->getPluginManager()->callEvent($ev);
|
||||
if(!$ev->isCancelled()){
|
||||
$this->attack($ev->getFinalDamage(), $ev);
|
||||
@ -675,7 +675,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
public function fall($fallDistance){
|
||||
$damage = floor($fallDistance - 3);
|
||||
if($damage > 0){
|
||||
$this->server->getPluginManager()->callEvent($ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_FALL, $damage));
|
||||
$this->server->getPluginManager()->callEvent($ev = EntityDamageEvent::createEvent($this, EntityDamageEvent::CAUSE_FALL, $damage));
|
||||
if($ev->isCancelled()){
|
||||
return;
|
||||
}
|
||||
@ -701,7 +701,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
|
||||
protected function switchLevel(Level $targetLevel){
|
||||
if($this->isValid()){
|
||||
$this->server->getPluginManager()->callEvent($ev = new EntityLevelChangeEvent($this, $this->level, $targetLevel));
|
||||
$this->server->getPluginManager()->callEvent($ev = EntityLevelChangeEvent::createEvent($this, $this->level, $targetLevel));
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
@ -1088,7 +1088,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
|
||||
public function setMotion(Vector3 $motion){
|
||||
if(!$this->justCreated){
|
||||
$this->server->getPluginManager()->callEvent($ev = new EntityMotionEvent($this, $motion));
|
||||
$this->server->getPluginManager()->callEvent($ev = EntityMotionEvent::createEvent($this, $motion));
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
@ -1139,7 +1139,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
}
|
||||
$from = Position::fromObject($this, $this->level);
|
||||
$to = Position::fromObject($pos, $pos instanceof Position ? $pos->getLevel() : $this->level);
|
||||
$this->server->getPluginManager()->callEvent($ev = new EntityTeleportEvent($this, $from, $to));
|
||||
$this->server->getPluginManager()->callEvent($ev = EntityTeleportEvent::createEvent($this, $from, $to));
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
@ -1177,7 +1177,7 @@ abstract class Entity extends Location implements Metadatable{
|
||||
|
||||
public function close(){
|
||||
if(!$this->closed){
|
||||
$this->server->getPluginManager()->callEvent(new EntityDespawnEvent($this));
|
||||
$this->server->getPluginManager()->callEvent(EntityDespawnEvent::createEvent($this));
|
||||
$this->closed = true;
|
||||
unset($this->level->updateEntities[$this->id]);
|
||||
if($this->chunk instanceof FullChunk){
|
||||
|
@ -115,7 +115,7 @@ class FallingBlock extends Entity{
|
||||
if(!$block->isFullBlock){
|
||||
$this->getLevel()->dropItem($this, Item::get($this->getBlock(), $this->getDamage(), 1));
|
||||
}else{
|
||||
$this->server->getPluginManager()->callEvent($ev = new EntityBlockChangeEvent($this, $block, Block::get($this->getBlock(), $this->getDamage())));
|
||||
$this->server->getPluginManager()->callEvent($ev = EntityBlockChangeEvent::createEvent($this, $block, Block::get($this->getBlock(), $this->getDamage())));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->getLevel()->setBlock($pos, $ev->getTo(), true);
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
return;
|
||||
}
|
||||
parent::kill();
|
||||
$this->server->getPluginManager()->callEvent($ev = new EntityDeathEvent($this, $this->getDrops()));
|
||||
$this->server->getPluginManager()->callEvent($ev = EntityDeathEvent::createEvent($this, $this->getDrops()));
|
||||
foreach($ev->getDrops() as $item){
|
||||
$this->getLevel()->dropItem($this, $item);
|
||||
}
|
||||
@ -135,7 +135,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
parent::entityBaseTick();
|
||||
|
||||
if($this->dead !== true and $this->isInsideOfSolid()){
|
||||
$this->server->getPluginManager()->callEvent($ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1));
|
||||
$this->server->getPluginManager()->callEvent($ev = EntityDamageEvent::createEvent($this, EntityDamageEvent::CAUSE_SUFFOCATION, 1));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->attack($ev->getFinalDamage(), $ev);
|
||||
}
|
||||
@ -146,7 +146,7 @@ abstract class Living extends Entity implements Damageable{
|
||||
if($this->airTicks <= -20){
|
||||
$this->airTicks = 0;
|
||||
|
||||
$this->server->getPluginManager()->callEvent($ev = new EntityDamageEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2));
|
||||
$this->server->getPluginManager()->callEvent($ev = EntityDamageEvent::createEvent($this, EntityDamageEvent::CAUSE_DROWNING, 2));
|
||||
if(!$ev->isCancelled()){
|
||||
$this->attack($ev->getFinalDamage(), $ev);
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ class PrimedTNT extends Entity implements Explosive{
|
||||
}
|
||||
|
||||
public function explode(){
|
||||
$this->server->getPluginManager()->callEvent($ev = new ExplosionPrimeEvent($this, 4));
|
||||
$this->server->getPluginManager()->callEvent($ev = ExplosionPrimeEvent::createEvent($this, 4));
|
||||
|
||||
if(!$ev->isCancelled()){
|
||||
$explosion = new Explosion($this, $ev->getForce(), $this);
|
||||
|
@ -24,16 +24,27 @@
|
||||
*/
|
||||
namespace pocketmine\event;
|
||||
|
||||
use pocketmine\plugin\PluginManager;
|
||||
|
||||
abstract class Event{
|
||||
|
||||
/**
|
||||
* Any callable event must declare the static variable
|
||||
*
|
||||
* public static $handlerList = null;
|
||||
* public static $eventPool = [];
|
||||
* public static $nextEvent = 0;
|
||||
*
|
||||
* Not doing so will deny the proper event initialization
|
||||
*/
|
||||
|
||||
/** @var Event[] */
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Event[] */
|
||||
private static $knownEvents = [];
|
||||
|
||||
protected $eventName = null;
|
||||
private $isCancelled = false;
|
||||
|
||||
@ -41,7 +52,7 @@ abstract class Event{
|
||||
* @return string
|
||||
*/
|
||||
final public function getEventName(){
|
||||
return $this->eventName !== null ? get_class($this) : $this->eventName;
|
||||
return $this->eventName !== null ? static::class : $this->eventName;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,4 +96,40 @@ abstract class Event{
|
||||
return static::$handlerList;
|
||||
}
|
||||
|
||||
public static function clearEventPool(){
|
||||
static::$nextEvent = 0;
|
||||
}
|
||||
|
||||
public static function clearAllPools(){
|
||||
foreach(self::$knownEvents as $event){
|
||||
$event::clearEventPool();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $params
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
public static function createEvent(...$params){
|
||||
if(static::$nextEvent >= count(static::$eventPool)){
|
||||
static::$eventPool[] = new static(...$params);
|
||||
return static::$eventPool[static::$nextEvent++];
|
||||
}
|
||||
$ev = static::$eventPool[static::$nextEvent++];
|
||||
$ev->__construct(...$params);
|
||||
if($ev instanceof Cancellable){
|
||||
$ev->setCancelled(false);
|
||||
}
|
||||
return $ev;
|
||||
}
|
||||
|
||||
public static function onClassLoaded(){
|
||||
self::$knownEvents[static::class] = static::class;
|
||||
}
|
||||
|
||||
public static function getKnownEvents(){
|
||||
return self::$knownEvents;
|
||||
}
|
||||
|
||||
}
|
@ -28,6 +28,8 @@ use pocketmine\Player;
|
||||
|
||||
class BlockBreakEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var \pocketmine\Player */
|
||||
protected $player;
|
||||
|
@ -26,6 +26,8 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class BlockFormEvent extends BlockGrowEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
public function __construct(Block $block, Block $newState){
|
||||
parent::__construct($block, $newState);
|
||||
|
@ -26,6 +26,8 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class BlockGrowEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Block */
|
||||
private $newState;
|
||||
|
@ -31,6 +31,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class BlockPlaceEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var \pocketmine\Player */
|
||||
protected $player;
|
||||
|
@ -26,6 +26,8 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class BlockSpreadEvent extends BlockFormEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Block */
|
||||
private $source;
|
||||
|
@ -30,5 +30,7 @@ use pocketmine\Player;
|
||||
*/
|
||||
class BlockUpdateEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
}
|
@ -26,6 +26,8 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class LeavesDecayEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
public function __construct(Block $block){
|
||||
parent::__construct($block);
|
||||
|
@ -30,6 +30,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class SignChangeEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var \pocketmine\Player */
|
||||
private $player;
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\item\Item;
|
||||
|
||||
class EntityArmorChangeEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $oldItem;
|
||||
private $newItem;
|
||||
|
@ -30,6 +30,8 @@ use pocketmine\event\Cancellable;
|
||||
*/
|
||||
class EntityBlockChangeEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $from;
|
||||
private $to;
|
||||
|
@ -25,6 +25,8 @@ use pocketmine\block\Block;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class EntityCombustByBlockEvent extends EntityCombustEvent{
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
protected $combuster;
|
||||
|
||||
|
@ -24,6 +24,8 @@ namespace pocketmine\event\entity;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class EntityCombustByEntityEvent extends EntityCombustEvent{
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
protected $combuster;
|
||||
|
||||
|
@ -26,6 +26,8 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class EntityCombustEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
protected $duration;
|
||||
|
||||
|
@ -25,6 +25,8 @@ use pocketmine\block\Block;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class EntityDamageByBlockEvent extends EntityDamageEvent{
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Block */
|
||||
private $damager;
|
||||
|
@ -24,6 +24,8 @@ namespace pocketmine\event\entity;
|
||||
use pocketmine\entity\Entity;
|
||||
|
||||
class EntityDamageByEntityEvent extends EntityDamageEvent{
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Entity */
|
||||
private $damager;
|
||||
|
@ -26,6 +26,8 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class EntityDamageEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
const MODIFIER_BASE = 0;
|
||||
const MODIFIER_ARMOR = 1;
|
||||
|
@ -26,6 +26,8 @@ use pocketmine\item\Item;
|
||||
|
||||
class EntityDeathEvent extends EntityEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Item[] */
|
||||
private $drops = [];
|
||||
|
@ -33,6 +33,8 @@ use pocketmine\entity\Vehicle;
|
||||
*/
|
||||
class EntityDespawnEvent extends EntityEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $entityType;
|
||||
|
||||
|
@ -31,6 +31,8 @@ use pocketmine\level\Position;
|
||||
*/
|
||||
class EntityExplodeEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Position */
|
||||
protected $position;
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\item\Item;
|
||||
|
||||
class EntityInventoryChangeEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $oldItem;
|
||||
private $newItem;
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\level\Level;
|
||||
|
||||
class EntityLevelChangeEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $originLevel;
|
||||
private $targetLevel;
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\math\Vector3;
|
||||
|
||||
class EntityMotionEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $mot;
|
||||
|
||||
|
@ -31,6 +31,8 @@ use pocketmine\math\Vector3;
|
||||
*/
|
||||
class EntityMoveEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var \pocketmine\math\Vector3 */
|
||||
private $pos;
|
||||
|
@ -26,6 +26,8 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class EntityRegainHealthEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
const CAUSE_REGEN = 0;
|
||||
const CAUSE_EATING = 1;
|
||||
|
@ -29,6 +29,8 @@ use pocketmine\item\Item;
|
||||
|
||||
class EntityShootBowEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Item */
|
||||
private $bow;
|
||||
|
@ -33,6 +33,8 @@ use pocketmine\entity\Vehicle;
|
||||
*/
|
||||
class EntitySpawnEvent extends EntityEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $entityType;
|
||||
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\level\Position;
|
||||
|
||||
class EntityTeleportEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Position */
|
||||
private $from;
|
||||
|
@ -29,6 +29,8 @@ use pocketmine\event\Cancellable;
|
||||
*/
|
||||
class ExplosionPrimeEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
protected $force;
|
||||
private $blockBreaking;
|
||||
|
@ -26,6 +26,8 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class ItemDespawnEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/**
|
||||
* @param DroppedItem $item
|
||||
|
@ -25,6 +25,8 @@ use pocketmine\entity\DroppedItem;
|
||||
|
||||
class ItemSpawnEvent extends EntityEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/**
|
||||
* @param DroppedItem $item
|
||||
|
@ -25,6 +25,8 @@ use pocketmine\entity\Projectile;
|
||||
|
||||
class ProjectileHitEvent extends EntityEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/**
|
||||
* @param Projectile $entity
|
||||
|
@ -26,6 +26,8 @@ use pocketmine\event\Cancellable;
|
||||
|
||||
class ProjectileLaunchEvent extends EntityEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/**
|
||||
* @param Projectile $entity
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\inventory\Recipe;
|
||||
|
||||
class CraftItemEvent extends Event implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var CraftingTransactionGroup */
|
||||
private $ts;
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\tile\Furnace;
|
||||
|
||||
class FurnaceBurnEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $furnace;
|
||||
private $fuel;
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\tile\Furnace;
|
||||
|
||||
class FurnaceSmeltEvent extends BlockEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $furnace;
|
||||
private $source;
|
||||
|
@ -26,6 +26,8 @@ use pocketmine\Player;
|
||||
|
||||
class InventoryCloseEvent extends InventoryEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Player */
|
||||
private $who;
|
||||
|
@ -27,6 +27,8 @@ use pocketmine\Player;
|
||||
|
||||
class InventoryOpenEvent extends InventoryEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Player */
|
||||
private $who;
|
||||
|
@ -27,6 +27,8 @@ use pocketmine\item\Item;
|
||||
|
||||
class InventoryPickupItemEvent extends InventoryEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Item */
|
||||
private $item;
|
||||
|
@ -31,6 +31,8 @@ use pocketmine\inventory\TransactionGroup;
|
||||
*/
|
||||
class InventoryTransactionEvent extends Event implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var TransactionGroup */
|
||||
private $ts;
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\level\format\FullChunk;
|
||||
*/
|
||||
class ChunkLoadEvent extends ChunkEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $newChunk;
|
||||
|
||||
|
@ -26,4 +26,6 @@ namespace pocketmine\event\level;
|
||||
*/
|
||||
class ChunkPopulateEvent extends ChunkEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
}
|
@ -28,4 +28,6 @@ use pocketmine\event\Cancellable;
|
||||
*/
|
||||
class ChunkUnloadEvent extends ChunkEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
}
|
@ -26,4 +26,6 @@ namespace pocketmine\event\level;
|
||||
*/
|
||||
class LevelInitEvent extends LevelEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
}
|
@ -26,4 +26,6 @@ namespace pocketmine\event\level;
|
||||
*/
|
||||
class LevelLoadEvent extends LevelEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
}
|
@ -26,4 +26,6 @@ namespace pocketmine\event\level;
|
||||
*/
|
||||
class LevelSaveEvent extends LevelEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
}
|
@ -28,4 +28,6 @@ use pocketmine\event\Cancellable;
|
||||
*/
|
||||
class LevelUnloadEvent extends LevelEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
}
|
@ -30,6 +30,8 @@ use pocketmine\level\Position;
|
||||
*/
|
||||
class SpawnChangeEvent extends LevelEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Position */
|
||||
private $previousSpawn;
|
||||
|
@ -29,6 +29,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerAchievementAwardedEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var string */
|
||||
protected $achievement;
|
||||
|
@ -29,6 +29,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerAnimationEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
const ARM_SWING = 1;
|
||||
|
||||
|
@ -27,6 +27,8 @@ use pocketmine\Player;
|
||||
|
||||
class PlayerBedEnterEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $bed;
|
||||
|
||||
|
@ -26,6 +26,8 @@ use pocketmine\Player;
|
||||
|
||||
class PlayerBedLeaveEvent extends PlayerEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $bed;
|
||||
|
||||
|
@ -27,6 +27,8 @@ use pocketmine\Player;
|
||||
|
||||
class PlayerBucketEmptyEvent extends PlayerBucketEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
public function __construct(Player $who, Block $blockClicked, $blockFace, Item $bucket, Item $itemInHand){
|
||||
parent::__construct($who, $blockClicked, $blockFace, $bucket, $itemInHand);
|
||||
|
@ -27,6 +27,8 @@ use pocketmine\Player;
|
||||
|
||||
class PlayerBucketFillEvent extends PlayerBucketEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
public function __construct(Player $who, Block $blockClicked, $blockFace, Item $bucket, Item $itemInHand){
|
||||
parent::__construct($who, $blockClicked, $blockFace, $bucket, $itemInHand);
|
||||
|
@ -30,6 +30,8 @@ use pocketmine\Server;
|
||||
*/
|
||||
class PlayerChatEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var string */
|
||||
protected $message;
|
||||
|
@ -34,6 +34,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerCommandPreprocessEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var string */
|
||||
protected $message;
|
||||
|
@ -27,6 +27,8 @@ use pocketmine\Player;
|
||||
|
||||
class PlayerDeathEvent extends EntityDeathEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $deathMessage;
|
||||
private $keepInventory = false;
|
||||
|
@ -30,6 +30,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerDropItemEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Item */
|
||||
private $drop;
|
||||
|
@ -29,6 +29,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerGameModeChangeEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var int */
|
||||
protected $gamemode;
|
||||
|
@ -31,6 +31,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerInteractEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/**
|
||||
* @var \pocketmine\block\Block;
|
||||
|
@ -30,6 +30,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerItemConsumeEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Item */
|
||||
private $item;
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\Player;
|
||||
|
||||
class PlayerItemHeldEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $item;
|
||||
private $slot;
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerJoinEvent extends PlayerEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var string */
|
||||
protected $joinMessage;
|
||||
|
@ -29,6 +29,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerKickEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var string */
|
||||
protected $quitMessage;
|
||||
|
@ -29,6 +29,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerLoginEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var string */
|
||||
protected $kickMessage;
|
||||
|
@ -27,6 +27,8 @@ use pocketmine\Player;
|
||||
|
||||
class PlayerMoveEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $from;
|
||||
private $to;
|
||||
|
@ -29,6 +29,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerPreLoginEvent extends PlayerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var string */
|
||||
protected $kickMessage;
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerQuitEvent extends PlayerEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var string */
|
||||
protected $quitMessage;
|
||||
|
@ -29,6 +29,8 @@ use pocketmine\Player;
|
||||
*/
|
||||
class PlayerRespawnEvent extends PlayerEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var Position */
|
||||
protected $position;
|
||||
|
@ -27,6 +27,8 @@ use pocketmine\plugin\Plugin;
|
||||
|
||||
class PluginDisableEvent extends PluginEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/**
|
||||
* @param Plugin $plugin
|
||||
|
@ -27,6 +27,8 @@ use pocketmine\plugin\Plugin;
|
||||
|
||||
class PluginEnableEvent extends PluginEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/**
|
||||
* @param Plugin $plugin
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\Player;
|
||||
|
||||
class DataPacketReceiveEvent extends ServerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $packet;
|
||||
private $player;
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\Player;
|
||||
|
||||
class DataPacketSendEvent extends ServerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
private $packet;
|
||||
private $player;
|
||||
|
@ -27,6 +27,8 @@ use pocketmine\utils\Binary;
|
||||
|
||||
class QueryRegenerateEvent extends ServerEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
const GAME_ID = "MINECRAFTPE";
|
||||
|
||||
|
@ -28,6 +28,8 @@ use pocketmine\command\CommandSender;
|
||||
*/
|
||||
class RemoteServerCommandEvent extends ServerCommandEvent{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/**
|
||||
* @param CommandSender $sender
|
||||
|
@ -34,6 +34,8 @@ use pocketmine\event\Cancellable;
|
||||
*/
|
||||
class ServerCommandEvent extends ServerEvent implements Cancellable{
|
||||
public static $handlerList = null;
|
||||
public static $eventPool = [];
|
||||
public static $nextEvent = 0;
|
||||
|
||||
/** @var string */
|
||||
protected $command;
|
||||
|
@ -131,7 +131,7 @@ abstract class BaseInventory implements Inventory{
|
||||
|
||||
$holder = $this->getHolder();
|
||||
if($holder instanceof Entity){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityInventoryChangeEvent($holder, $this->getItem($index), $item, $index));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = EntityInventoryChangeEvent::createEvent($holder, $this->getItem($index), $item, $index));
|
||||
if($ev->isCancelled()){
|
||||
$this->sendContents($this->getViewers());
|
||||
|
||||
@ -298,7 +298,7 @@ abstract class BaseInventory implements Inventory{
|
||||
$old = $this->slots[$index];
|
||||
$holder = $this->getHolder();
|
||||
if($holder instanceof Entity){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityInventoryChangeEvent($holder, $old, $item, $index));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = EntityInventoryChangeEvent::createEvent($holder, $old, $item, $index));
|
||||
if($ev->isCancelled()){
|
||||
$this->sendContents($this->getViewers());
|
||||
|
||||
@ -350,7 +350,7 @@ abstract class BaseInventory implements Inventory{
|
||||
}
|
||||
|
||||
public function open(Player $who){
|
||||
$who->getServer()->getPluginManager()->callEvent($ev = new InventoryOpenEvent($this, $who));
|
||||
$who->getServer()->getPluginManager()->callEvent($ev = InventoryOpenEvent::createEvent($this, $who));
|
||||
if($ev->isCancelled()){
|
||||
return false;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ class CraftingTransactionGroup extends SimpleTransactionGroup{
|
||||
return false;
|
||||
}
|
||||
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new CraftItemEvent($this, $this->getMatchingRecipe()));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = CraftItemEvent::createEvent($this, $this->getMatchingRecipe()));
|
||||
if($ev->isCancelled()){
|
||||
foreach($this->inventories as $inventory){
|
||||
$inventory->sendContents($inventory->getViewers());
|
||||
|
@ -103,7 +103,7 @@ class PlayerInventory extends BaseInventory{
|
||||
if($slot >= -1 and $slot < $this->getSize()){
|
||||
$item = $this->getItem($slot);
|
||||
if($this->getHolder() instanceof Player){
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new PlayerItemHeldEvent($this->getHolder(), $item, $slot, $this->itemInHandIndex));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = PlayerItemHeldEvent::createEvent($this->getHolder(), $item, $slot, $this->itemInHandIndex));
|
||||
if($ev->isCancelled()){
|
||||
$this->sendHeldItem($this->getHolder());
|
||||
|
||||
@ -203,7 +203,7 @@ class PlayerInventory extends BaseInventory{
|
||||
}
|
||||
|
||||
if($index >= $this->getSize()){ //Armor change
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityArmorChangeEvent($this->getHolder(), $this->getItem($index), $item, $index));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = EntityArmorChangeEvent::createEvent($this->getHolder(), $this->getItem($index), $item, $index));
|
||||
if($ev->isCancelled() and $this->getHolder() instanceof Player){
|
||||
$this->sendArmorContents($this->getViewers());
|
||||
$this->sendContents($this->getViewers());
|
||||
@ -229,7 +229,7 @@ class PlayerInventory extends BaseInventory{
|
||||
$item = Item::get(Item::AIR, null, 0);
|
||||
$old = $this->slots[$index];
|
||||
if($index >= $this->getSize() and $index < $this->size){ //Armor change
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = new EntityArmorChangeEvent($this->getHolder(), $old, $item, $index));
|
||||
Server::getInstance()->getPluginManager()->callEvent($ev = EntityArmorChangeEvent::createEvent($this->getHolder(), $old, $item, $index));
|
||||
if($ev->isCancelled()){
|
||||
$this->sendArmorContents($this->getViewers());
|
||||
$this->sendContents($this->getViewers());
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user