setDrops() public method

public setDrops ( array $drops )
$drops array
Beispiel #1
0
 public function onBreak(BlockBreakEvent $event)
 {
     if ($event->getBlock()->getId() == 15) {
         $drops = array(Item::get(265, 0, 1));
         $event->setDrops($drops);
     }
     if ($event->getBlock()->getId() == 14) {
         $drops = array(Item::get(266, 0, 1));
         $event->setDrops($drops);
     }
 }
Beispiel #2
0
 public function onBreak(BlockBreakEvent $ev)
 {
     $p = $ev->getPlayer();
     $block = $ev->getBlock();
     $item = $ev->getItem()->getId();
     $ev->setInstaBreak(true);
     foreach ($this->ores as $ore) {
         if ($block->getId() === $ore && !$ev->isCancelled()) {
             $ev->setDrops(array());
             $p->sendMessage("§l§dAUTO-SMELTED!");
             $p->getInventory()->addItem(Item::get($this->ingot[$ore]));
             $x = $p->getX();
             $y = $p->getY();
             $z = $p->getZ();
             $p->getLevel()->addSound(new FizzSound(new Vector3($x, $y, $z)));
         }
     }
 }
Beispiel #3
0
 public function onBreak(BlockBreakEvent $event)
 {
     $player = $event->getPlayer();
     $name = $player->getName();
     $block = $event->getBlock();
     $block2 = $player->getLevel()->getBlock(new Vector3($block->getX(), $block->getY() - 1, $block->getZ()), false);
     if ($this->inArena($player)) {
         $arena = $this->getArena($player);
         $config = new Config($this->getDataFolder() . "Arenas/" . $arena . ".yml", Config::YAML);
         $team = $this->getTeamByBed($arena, $block);
         if ($config->get("Status") != "Lobby") {
             if ($block->getId() == Block::BED_BLOCK) {
                 if ($team != $this->getTeam($player->getNameTag())) {
                     $config->setNested("Bed." . $team . ".Alive", false);
                     $config->save();
                     $event->setDrops(array());
                     $player->sendMessage($this->prefix . "Du hast das Bett von Team " . $team . " zerstört!");
                     foreach ($this->getPlayers($arena) as $pn) {
                         $p = $this->getServer()->getPlayerExact($pn);
                         if ($p != null) {
                             if ($team == $this->getTeam($p->getNameTag())) {
                                 $p->sendMessage($this->prefix . TextFormat::RED . "Das Bett von deinem Team wurde zerstört!");
                             } else {
                                 $p->sendMessage($this->prefix . "Das Bett von Team " . TextFormat::GOLD . $team . TextFormat::WHITE . " wurde zerstört!");
                             }
                         }
                     }
                 } else {
                     $player->sendMessage($this->prefix . "Du kannst dein eigenes Bett nicht zerstören!");
                     $event->setCancelled();
                 }
             } elseif (!in_array($block->getId(), $this->breakableblocks)) {
                 $event->setCancelled();
             }
         } else {
             $event->setCancelled();
         }
     }
 }