Merge pull request #3507 from alejandroliu/crafting-event

Added Player to CraftItemEvent
This commit is contained in:
Shoghi Cervantes 2015-09-27 14:05:38 +02:00
commit a7e5e33db8
2 changed files with 18 additions and 6 deletions

View File

@ -2719,7 +2719,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
break;
}
$this->server->getPluginManager()->callEvent($ev = new CraftItemEvent($ingredients, $recipe));
$this->server->getPluginManager()->callEvent($ev = new CraftItemEvent($this, $ingredients, $recipe));
if($ev->isCancelled()){
$this->inventory->sendContents($this);

View File

@ -25,6 +25,7 @@ use pocketmine\event\Cancellable;
use pocketmine\event\Event;
use pocketmine\inventory\Recipe;
use pocketmine\item\Item;
use pocketmine\Player;
class CraftItemEvent extends Event implements Cancellable{
public static $handlerList = null;
@ -33,12 +34,17 @@ class CraftItemEvent extends Event implements Cancellable{
private $input = [];
/** @var Recipe */
private $recipe;
/** @var \pocketmine\Player */
private $player;
/**
* @param \pocketmine\Player $player
* @param Item[] $input
* @param Recipe $recipe
*/
public function __construct(array $input, Recipe $recipe){
public function __construct(Player $player, array $input, Recipe $recipe){
$this->player = $player;
$this->input = $input;
$this->recipe = $recipe;
}
@ -62,4 +68,10 @@ class CraftItemEvent extends Event implements Cancellable{
return $this->recipe;
}
/**
* @return \pocktemine\Player
*/
public function getPlayer(){
return $this->player;
}
}