Added Player to CraftItemEvent

This commit is contained in:
Alejandro Liu 2015-09-19 23:08:57 +02:00
parent 86c1198648
commit 6273875a22
2 changed files with 18 additions and 6 deletions

View File

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

View File

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