コード例 #1
0
 private function deactivate(Player $pl)
 {
     $pl->sendMessage(mc::_("CloakClock de-actived"));
     $this->owner->setState("CloakClock", $pl, false);
     foreach ($this->owner->getServer()->getOnlinePlayers() as $online) {
         $online->showPlayer($pl);
     }
 }
コード例 #2
0
 public function inGame(CommandSender $sender, $msg = true)
 {
     if (!$sender instanceof Player) {
         if ($msg) {
             $sender->sendMessage(mc::_("You can only do this in-game"));
         }
         return false;
     }
     return true;
 }
コード例 #3
0
ファイル: CompassTp.php プロジェクト: DWWf/pocketmine-plugins
 public function onPlayerInteract(PlayerInteractEvent $e)
 {
     // Implement the CompassTP thingie...
     $pl = $e->getPlayer();
     if (!$pl->hasPermission("toybox.compasstp")) {
         return;
     }
     $hand = $pl->getInventory()->getItemInHand();
     if ($hand->getID() != $this->item) {
         return;
     }
     $pos = $pl->getPosition()->add(0, $pl->getEyeHeight(), 0);
     $start = new Vector3($pos->getX(), $pos->getY(), $pos->getZ());
     $lv = $pl->getLevel();
     for ($start = new Vector3($pos->getX(), $pos->getY(), $pos->getZ()); $start->distance($pos) < 120; $pos = $pos->add($pl->getDirectionVector())) {
         $block = $lv->getBlock($pos->floor());
         if ($block->getId() != 0) {
             break;
         }
     }
     if ($block->getId() == 0) {
         $pl->sendMessage(mc::_("Can not teleport to the void!"));
         return;
     }
     $pos = $pos->subtract($pl->getDirectionVector());
     $dist = $start->distance($pos);
     if ($dist < 2.8) {
         $pl->sendMessage(mc::_("Not teleporting..."));
         $pl->sendMessage(mc::_("You could easily walk there!"));
         return;
     }
     //echo "Block: ".$block->getName()." (".$block->getId().")\n";
     //print_r($pos);
     //echo "Distance: ".$start->distance($pos)."\n";
     $pl->sendMessage(mc::_("Teleporting... %1%", intval($dist)));
     $pos = $pos->add(0, 1, 0);
     /*$cb = new CallbackTask([$this,"delayedTP"],[$pl->getName(),
       $pos->getX(),
       $pos->getY(),
       $pos->getZ()]);
       $this->owner->getServer()->getScheduler()->scheduleDelayedTask($cb,20);
       //$pl->teleport($pos);
       return;*/
     $m = 5.0;
     for ($f = 1.0; $f <= $m; $f++) {
         $ticks = intval($f) * 5;
         $x = ($pos->getX() - $start->getX()) * $f / $m + $start->getX();
         $y = ($pos->getY() - $start->getY()) * $f / $m + $start->getY();
         $z = ($pos->getZ() - $start->getZ()) * $f / $m + $start->getZ();
         $c = new PluginCallbackTask($this->owner, [$this, "delayedTP"], [$pl->getName(), $x, $y, $z]);
         $this->owner->getServer()->getScheduler()->scheduleDelayedTask($c, $ticks);
     }
 }
コード例 #4
0
 public function __construct($plugin, $cfg)
 {
     $this->owner = $plugin;
     $this->blocks = [];
     if (isset($cfg["blocks"]) && is_array($cfg["blocks"])) {
         foreach ($cfg["blocks"] as $i) {
             $item = $this->owner->getItem($i, false, "trampoline");
             if ($item === null) {
                 continue;
             }
             $this->blocks[$item->getId()] = $item->getId();
         }
     }
     if (count($this->blocks)) {
         $this->owner->getServer()->getPluginManager()->registerEvents($this, $this->owner);
         $this->owner->getLogger()->info(TextFormat::GREEN . mc::_("Trampoline blocks: %1%", count($this->blocks)));
     } else {
         $this->getLogger()->warning(TextFormat::RED . mc::_("No blocks configured"));
     }
 }
コード例 #5
0
ファイル: PowerTool.php プロジェクト: DWWf/pocketmine-plugins
 public function onCommand(CommandSender $sender, Command $cmd, $label, array $args)
 {
     if ($cmd->getName() != "powertool") {
         return false;
     }
     if (!$this->inGame($sender)) {
         return true;
     }
     if (count($args) != 0) {
         return false;
     }
     $state = $this->getState($sender, false);
     if ($state) {
         $sender->sendMessage(mc::_("PowerTool de-actived"));
         $this->setState($sender, false);
     } else {
         $sender->sendMessage(mc::_("PowerTool activated"));
         $this->setState($sender, true);
     }
     return true;
 }
コード例 #6
0
ファイル: Main.php プロジェクト: DWWf/pocketmine-plugins
 public function getItem($txt, $default = 0, $msg = "")
 {
     $r = explode(":", $txt);
     if (count($r)) {
         if (!isset($r[1])) {
             $r[1] = 0;
         }
         $item = Item::fromString($r[0] . ":" . $r[1]);
         if (isset($r[2])) {
             $item->setCount(intval($r[2]));
         }
         if ($item->getId() != Item::AIR) {
             return $item;
         }
     }
     if ($default) {
         if ($msg != "") {
             $this->getLogger()->warning(mc::_("%1%: Invalid item %2%, using default", $msg, $txt));
         }
         $item = Item::fromString($default . ":0");
         $item->setCount(1);
         return $item;
     }
     if ($msg != "") {
         $this->getLogger()->warning(mc::_("%1%: Invalid item %2%, ignoring", $msg, $txt));
     }
     return null;
 }
コード例 #7
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));
     }
 }
コード例 #8
0
 public function onBlockBreak(BlockBreakEvent $ev)
 {
     if ($ev->isCancelled()) {
         return;
     }
     $pl = $ev->getPlayer();
     if (!$this->getState($pl, false)) {
         return;
     }
     if (!$pl->isCreative() || !$this->creative) {
         if ($this->items && !isset($this->items[$ev->getItem()->getId()])) {
             echo "Not using an Axe\n";
             //##DEBUG
             return;
         }
     }
     if ($this->leaves) {
         $damage = $this->destroyTree($ev->getBlock());
     } else {
         $damage = $this->destroyTrunk($ev->getBlock());
     }
     if ($damage && $this->items && $this->itemwear) {
         $hand = $pl->getInventory()->getItemInHand();
         $hand->setDamage($hand->getDamage() + $this->itemwear * $damage);
         $pl->getInventory()->setItemInHand($hand);
         if ($this->broadcast) {
             $this->owner->getServer()->broadcastMessage(mc::_("%1% used TreeCapitator", $pl->getName()));
         } else {
             $pl->sendMessage(mc::_("Used TreeCapitator"));
         }
     }
 }
コード例 #9
0
 /**
  * @priority LOWEST
  */
 public function onPlayerTeleport(EntityTeleportEvent $e)
 {
     $pl = $e->getEntity();
     if (!$pl instanceof Player) {
         return;
     }
     $state = $this->getState($pl, null);
     if ($state) {
         $this->deSpawn($pl, $state[1]);
         $this->unsetState($pl);
         $pl->sendMessage(mc::_("Magic carpet lost due to teleport!"));
     }
 }
コード例 #10
0
ファイル: TorchMgr.php プロジェクト: DWWf/pocketmine-plugins
 public function onInteract(PlayerInteractEvent $e)
 {
     // Activate torch
     $pl = $e->getPlayer();
     if (!$pl->hasPermission("toybox.torch")) {
         return;
     }
     $bl = $e->getBlock();
     if ($bl->isSolid()) {
         return;
     }
     $hand = $pl->getInventory()->getItemInHand();
     if ($hand->getID() != $this->item) {
         return;
     }
     $state = $this->owner->getState("Torch", $pl, null);
     if ($state) {
         $this->deSpawnTorch($pl);
         $pl->sendMessage(mc::_("Torch de-activated"));
     } else {
         $this->spawnTorch($pl);
         $pl->sendMessage(mc::_("Torch activated"));
     }
 }