コード例 #1
0
ファイル: VeinMiner.php プロジェクト: DWWf/pocketmine-plugins
 public function onBreak(BlockBreakEvent $ev)
 {
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getPlayer();
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     if (($m = $this->getState($pl, false)) === false) {
         return;
     }
     echo __METHOD__ . "," . __LINE__ . ":: m={$m}\n";
     //##DEBUG
     if ($m === "insta-break") {
         $ev->setInstaBreak(true);
         return;
     }
     echo __METHOD__ . "," . __LINE__ . "\n";
     //##DEBUG
     if ($ev->getBlock()->getId() == Block::AIR) {
         return;
     }
     if (!$pl->isCreative() || !$this->creative) {
         if ($this->items && !isset($this->items[$ev->getItem()->getId()])) {
             //echo "Not using an PickAxe\n"; //##DEBUG
             return;
         }
     }
     if (substr($ev->getBlock()->getName(), -4) !== " Ore") {
         return;
     }
     // This is an ore...
     $ev->setInstaBreak(true);
     $pl->sendMessage(mc::_("Using VeinMinger"));
     $this->setState($pl, "insta-break");
     //prevents infinite loops...
     $c = $this->veinsearch($ev->getBlock(), $this->blocklimit, $pl, $this->sides);
     $this->setState($pl, true);
     if ($c && $this->broadcast) {
         $this->owner->getServer()->broadcastMessage(mc::n(mc::_("%1% used VeinMiner (one block affected)", $pl->getDisplayName()), mc::_("%1% used VeinMiner (%2% blocks affected)", $pl->getDisplayName(), $c), $c));
     }
 }