Added ItemDespawnEvent

This commit is contained in:
Shoghi Cervantes 2014-10-08 16:51:10 +02:00
parent 3313981d54
commit c750a204e6
2 changed files with 55 additions and 1 deletions

View File

@ -23,6 +23,7 @@ namespace pocketmine\entity;
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\EntityRegainHealthEvent;
use pocketmine\event\entity\ItemDespawnEvent;
use pocketmine\item\Item;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\Byte;
@ -105,7 +106,12 @@ class DroppedItem extends Entity{
}
if($this->age > 6000){
$this->kill();
$this->server->getPluginManager()->callEvent($ev = new ItemDespawnEvent($this));
if($ev->isCancelled()){
$this->age = 0;
}else{
$this->kill();
}
}
}

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/
*
*
*/
namespace pocketmine\event\entity;
use pocketmine\block\Block;
use pocketmine\entity\DroppedItem;
use pocketmine\entity\Entity;
use pocketmine\event\Cancellable;
use pocketmine\level\Position;
class ItemDespawnEvent extends EntityEvent implements Cancellable{
public static $handlerList = null;
/**
* @param DroppedItem $item
*/
public function __construct(DroppedItem $item){
$this->entity = $item;
}
/**
* @return DroppedItem
*/
public function getEntity(){
return $this->entity;
}
}