当前位置: 首页>>代码示例>>PHP>>正文


PHP SignChangeEvent::setCancelled方法代码示例

本文整理汇总了PHP中pocketmine\event\block\SignChangeEvent::setCancelled方法的典型用法代码示例。如果您正苦于以下问题:PHP SignChangeEvent::setCancelled方法的具体用法?PHP SignChangeEvent::setCancelled怎么用?PHP SignChangeEvent::setCancelled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\event\block\SignChangeEvent的用法示例。


在下文中一共展示了SignChangeEvent::setCancelled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: signPlace

 public function signPlace(SignChangeEvent $event)
 {
     if ($event->getPlayer()->isOp()) {
         return;
     }
     $message = "";
     foreach ($event->getLines() as $line) {
         $message .= $line;
     }
     $find = $this->checkSwearWord($message);
     if ($find != null) {
         $event->getPlayer()->sendMessage(TextFormat::RED . $this->get("some-badwords-found") . ": " . $message . " ( " . $find . " ) ");
         $event->getPlayer()->sendMessage(TextFormat::RED . $this->get("you-need-to-change-your-name"));
         $event->setCancelled();
         $this->cautionNotice($event->getPlayer(), $message . " ( " . $find . " ) ");
         return;
     }
     if (isset($this->oldSign[$event->getPlayer()->getName()])) {
         $find = $this->checkSwearWord($this->oldSign[$event->getPlayer()->getName()] . $message);
         if ($find != null) {
             $event->getPlayer()->sendMessage(TextFormat::RED . $this->get("some-badwords-found") . ": " . $find);
             $event->getPlayer()->sendMessage(TextFormat::RED . $this->get("you-need-to-change-your-name"));
             $event->setCancelled();
             $this->cautionNotice($event->getPlayer(), $find);
             return;
         }
     }
     $this->oldSign[$event->getPlayer()->getName()] = $message;
 }
开发者ID:EmreTr1,项目名称:rtr,代码行数:29,代码来源:Gentleman.php

示例2: onSign

 public function onSign(SignChangeEvent $event)
 {
     if ($event->getLine(0) == "[워프]" or $event->getLine(0) == "워프") {
         $player = $event->getPlayer();
         if (!$player->hasPermission("nyduscanal.commands.addwarp")) {
             $player->sendMessage(TextFormat::DARK_AQUA . "포탈생성권한이 없습니다.");
             $event->setCancelled();
             return false;
         }
         if (!isset(explode("[", $event->getLine(1))[1])) {
             if (!isset($this->NydusCanal_List["warp"][$event->getLine(1)])) {
                 $player->sendMessage(TextFormat::DARK_AQUA . "해당하는 워프포인트가 없습니다.");
                 $event->setCancelled();
                 return false;
             }
         }
         $event->setLine(0, "[워프]");
         if (isset($this->NydusCanal_List["warp"][$event->getLine(1)]["price"])) {
             if (isset(explode("+", $this->NydusCanal_List["warp"][$event->getLine(1)]["price"])[1])) {
                 $event->setLine(2, "보상:" . explode("+", $this->NydusCanal_List["warp"][$event->getLine(1)]["price"])[1] . "\$");
             } else {
                 $event->setLine(2, "비용:" . $this->NydusCanal_List["warp"][$event->getLine(1)]["price"] . "\$");
             }
         }
         $player->sendMessage("포탈생성이 완료되었습니다.");
         $block = $event->getBlock();
         $this->NydusCanal_List["signs"][$player->getLevel()->getFolderName()][$block->x . ":" . $block->y . ":" . $block->z] = $event->getLine(1);
         if ($event->getLine(2) == "x") {
             $this->NydusCanal_List["touch-signs"][$player->getLevel()->getFolderName()][$block->x . ":" . $block->y . ":" . $block->z] = 1;
             $event->setLine(2, "");
         }
     }
 }
开发者ID:Gumbrat,项目名称:Pocketmine-Plugins,代码行数:33,代码来源:AdvancedWarps.php

示例3: onSignChange

 /**
  * @param SignChangeEvent $event
  * @priority HIGHEST
  * @ignoreCancelled true
  */
 public function onSignChange(SignChangeEvent $event)
 {
     if (!$this->plugin->getStorage()->getShield($event->getBlock()->getLevel())->isAllowed(Shield::EDITING)) {
         $event->setCancelled(true);
         $event->getPlayer()->sendTip($this->plugin->getConfig()->get("signChangeNotAllowed"));
     }
 }
开发者ID:NameNoOne100,项目名称:PocketMine-Plugins,代码行数:12,代码来源:GlobalShieldListener.php

示例4: onSignChange

 public function onSignChange(SignChangeEvent $event)
 {
     if (strtolower(TextFormat::clean($event->getLine(0))) === "[advancedkits]" and !$event->getPlayer()->hasPermission("advancedkits.admin")) {
         $event->getPlayer()->sendMessage($this->ak->langManager->getTranslation("no-perm-sign"));
         $event->setCancelled();
     }
 }
开发者ID:Nader6,项目名称:AdvancedKits,代码行数:7,代码来源:EventListener.php

示例5: onSignChange

 public function onSignChange(SignChangeEvent $event)
 {
     if ($event->getLine(0) === $this->getPlugin()->getConfig()->get('sign-trigger')) {
         if ($event->getPlayer()->hasPermission("battlekits.sign.create")) {
             if (!empty($event->getLine(1))) {
                 $event->getPlayer()->sendMessage("You have successfully created kit sign.");
             } else {
                 $event->getPlayer()->sendMessage("You must set a kit.");
                 $event->setCancelled();
             }
         } else {
             $event->getPlayer()->sendMessage("You don't have permission to make kit signs.");
             $event->setCancelled();
         }
     }
 }
开发者ID:haruajsuru,项目名称:BattleKits,代码行数:16,代码来源:SignListener.php

示例6: onSignChange

 /**
  * Sign change
  *
  * @param SignChangeEvent $event
  */
 public function onSignChange(SignChangeEvent $event)
 {
     if (strtolower($event->getPlayer()->getLevel()->getName()) === strtolower($this->plugin->hubLevelName)) {
         $player = $event->getPlayer();
         $block = $event->getBlock();
         $line1 = $event->getLine(0);
         $line2 = $event->getLine(1);
         $line3 = $event->getLine(2);
         $line4 = $event->getLine(3);
         if (!$event->getPlayer()->isOp()) {
             $event->getPlayer()->sendMessage("[HG] You are not authorized to use this command.");
             $event->setCancelled(true);
         } else {
             if ($line1 != null && $line1 === "hungergame") {
                 if ($line2 != null && $line2 === "arena") {
                     if ($line3 != null && $line3 === "join") {
                         $arenaName = $line4;
                         $this->plugin->arenaManager->handleSetSignJoin($player, $arenaName, $block);
                     }
                 }
             }
             if ($line1 != null && $line1 === "hungergame") {
                 if ($line2 != null && $line2 === "arena") {
                     if ($line3 != null && $line3 === "vote") {
                         $arenaName = $line4;
                         $this->plugin->arenaManager->handleSetSignVote($player, $arenaName, $block);
                     }
                 }
             }
             if ($line1 != null && $line1 === "hungergame") {
                 if ($line2 != null && $line2 === "arena") {
                     if ($line3 != null && $line3 === "exit") {
                         $arenaName = $line4;
                         $this->plugin->arenaManager->handleSetSignExit($player, $arenaName, $block);
                     }
                 }
             }
             if ($line1 != null && $line1 === "hungergame") {
                 if ($line2 != null && $line2 === "arena") {
                     if ($line3 != null && $line3 === "stat") {
                         $arenaName = $line4;
                         $this->plugin->arenaManager->handleSetSignStat($player, $arenaName, $block);
                     }
                 }
             }
         }
     }
 }
开发者ID:robozeri,项目名称:SG,代码行数:53,代码来源:MapArenaListener.php

示例7: onSignChange

 public function onSignChange(SignChangeEvent $event)
 {
     $player = $event->getPlayer();
     if ($player->hasPermission("worldstats.place")) {
         if (TextFormat::clean(strtolower(trim($event->getLine(0)))) === strtolower(trim($this->sign->get("sign_trigger"))) || TextFormat::clean(strtolower(trim($event->getLine(0)))) === strtolower(trim($this->sign->get("sign_final_change")))) {
             $world = $event->getLine(1);
             $level = $this->getServer()->getLevelByName($world);
             if ($level instanceof Level) {
                 $players = count($level->getPlayers());
                 $event->setLine(0, TextFormat::GREEN . $this->sign->get("sign_final_change"));
                 $event->setLine(2, TextFormat::YELLOW . $players . TextFormat::RED . " players");
             } else {
                 $event->setLine(0, TextFormat::DARK_RED . "()()()()()()");
                 $event->setLine(1, TextFormat::DARK_RED . "*****");
                 $event->setLine(2, TextFormat::RED . "World Name Error");
                 $event->setLine(3, TextFormat::DARK_RED . "******");
             }
         }
     } else {
         $player->sendMessage(TextFormat::RED . "You do not have permission to create a World Status sign.");
         $event->setCancelled(true);
     }
 }
开发者ID:gitter-badger,项目名称:Development-1,代码行数:23,代码来源:WorldStats.php

示例8: handleDataPacket


//.........这里部分代码省略.........
                         $this->level->setBlock($block, new Air());
                         break;
                     }
                     $this->lastBreak = microtime(true);
                     break;
                 case PlayerActionPacket::ACTION_ABORT_BREAK:
                     $this->lastBreak = PHP_INT_MAX;
                     break;
                 case PlayerActionPacket::ACTION_RELEASE_ITEM:
                     if ($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)) {
                         if ($this->inventory->getItemInHand()->getId() === Item::BOW) {
                             $bow = $this->inventory->getItemInHand();
                             if ($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, null))) {
                                 $this->inventory->sendContents($this);
                                 break;
                             }
                             $arrow = false;
                             foreach ($this->inventory->getContents() as $item) {
                                 if ($item->getId() == Item::ARROW) {
                                     $arrow = $item;
                                 }
                             }
                             if ($arrow === false and $this->isCreative()) {
                                 $arrow = Item::get(Item::ARROW, 0, 1);
                             } elseif ($arrow === false) {
                                 break;
                             }
                             $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)]), "Fire" => new ShortTag("Fire", $this->isOnFire() ? 45 * 60 : 0), "Potion" => new ShortTag("Potion", $arrow->getDamage())]);
                             $diff = $this->server->getTick() - $this->startAction;
                             $p = $diff / 20;
                             $f = min(($p ** 2 + $p * 2) / 3, 1) * 2;
                             $ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f);
                             if ($f < 0.1 or $diff < 5) {
                                 $ev->setCancelled();
                             }
                             $this->server->getPluginManager()->callEvent($ev);
                             if ($ev->isCancelled()) {
                                 $ev->getProjectile()->kill();
                                 $this->inventory->sendContents($this);
                             } else {
                                 $ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
                                 if ($this->isSurvival()) {
                                     $this->inventory->removeItem(Item::get(Item::ARROW, $arrow->getDamage(), 1));
                                     $bow->setDamage($bow->getDamage() + 1);
                                     if ($bow->getDamage() >= 385) {
                                         $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0));
                                     } else {
                                         $this->inventory->setItemInHand($bow);
                                     }
                                 }
                                 if ($ev->getProjectile() instanceof Projectile) {
                                     $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
                                     if ($projectileEv->isCancelled()) {
                                         $ev->getProjectile()->kill();
                                     } else {
                                         $ev->getProjectile()->spawnToAll();
                                         $this->level->addSound(new LaunchSound($this), $this->getViewers());
                                     }
                                 } else {
                                     $ev->getProjectile()->spawnToAll();
                                 }
                             }
                         }
                     } elseif ($this->inventory->getItemInHand()->getId() === Item::BUCKET and $this->inventory->getItemInHand()->getDamage() === 1) {
                         //Milk!
                         $this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $this->inventory->getItemInHand()));
开发者ID:robske110,项目名称:ClearSky,代码行数:67,代码来源:Player.php

示例9: handleDataPacket


//.........这里部分代码省略.........
             $this->craftingType = 0;
             $packet->eid = $this->id;
             $pos = new Vector3($packet->x, $packet->y, $packet->z);
             switch ($packet->action) {
                 case 0:
                     //Start break
                     if ($pos->distanceSquared($this) > 10000) {
                         break;
                     }
                     $target = $this->level->getBlock($pos);
                     $ev = new PlayerInteractEvent($this, $this->inventory->getItemInHand(), $target, $packet->face, $target->getId() === 0 ? PlayerInteractEvent::LEFT_CLICK_AIR : PlayerInteractEvent::LEFT_CLICK_BLOCK);
                     $this->getServer()->getPluginManager()->callEvent($ev);
                     if ($ev->isCancelled()) {
                         $this->inventory->sendHeldItem($this);
                         break;
                     }
                     $this->lastBreak = microtime(true);
                     break;
                 case 5:
                     //Shot arrow
                     if ($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)) {
                         if ($this->inventory->getItemInHand()->getId() === Item::BOW) {
                             $bow = $this->inventory->getItemInHand();
                             if ($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, 0, 1))) {
                                 $this->inventory->sendContents($this);
                                 break;
                             }
                             $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $this->x), new Double("", $this->y + $this->getEyeHeight()), new Double("", $this->z)]), "Motion" => new Enum("Motion", [new Double("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new Double("", -sin($this->pitch / 180 * M_PI)), new Double("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new Enum("Rotation", [new Float("", $this->yaw), new Float("", $this->pitch)])]);
                             $diff = $this->server->getTick() - $this->startAction;
                             $p = $diff / 20;
                             $f = min(($p ** 2 + $p * 2) / 3, 1) * 2;
                             $ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f);
                             if ($f < 0.1 or $diff < 5) {
                                 $ev->setCancelled();
                             }
                             $this->server->getPluginManager()->callEvent($ev);
                             if ($ev->isCancelled()) {
                                 $ev->getProjectile()->kill();
                                 $this->inventory->sendContents($this);
                             } else {
                                 $ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
                                 if ($this->isSurvival()) {
                                     $this->inventory->removeItem(Item::get(Item::ARROW, 0, 1));
                                     $bow->setDamage($bow->getDamage() + 1);
                                     if ($bow->getDamage() >= 385) {
                                         $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0));
                                     } else {
                                         $this->inventory->setItemInHand($bow);
                                     }
                                 }
                                 if ($ev->getProjectile() instanceof Projectile) {
                                     $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
                                     if ($projectileEv->isCancelled()) {
                                         $ev->getProjectile()->kill();
                                     } else {
                                         $ev->getProjectile()->spawnToAll();
                                         $this->level->addSound(new LaunchSound($this), $this->getViewers());
                                     }
                                 } else {
                                     $ev->getProjectile()->spawnToAll();
                                 }
                             }
                         }
                     } elseif ($this->inventory->getItemInHand()->getId() === Item::BUCKET and $this->inventory->getItemInHand()->getDamage() === 1) {
                         //Milk!
                         $this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $this->inventory->getItemInHand()));
开发者ID:TylerGames,项目名称:PocketMine-MP,代码行数:67,代码来源:Player.php

示例10: onSignChange

 /**
  * @param SignChangeEvent $event
  */
 public function onSignChange(SignChangeEvent $event)
 {
     // Special Signs
     // Free sign
     if (strtolower(TextFormat::clean($event->getLine(0), true)) === "[free]" && $event->getPlayer()->hasPermission("essentials.sign.create.free")) {
         if (trim($event->getLine(1)) !== "" || $event->getLine(1) !== null) {
             $item_name = $event->getLine(1);
             if (trim($event->getLine(2)) !== "" || $event->getLine(2) !== null) {
                 $damage = $event->getLine(2);
             } else {
                 $damage = 0;
             }
             $item = $this->getAPI()->getItem($item_name . ":" . $damage);
             if ($item->getID() === 0 || $item->getName() === "Air") {
                 $event->getPlayer()->sendMessage(TextFormat::RED . "[Error] Invalid item name/ID");
                 $event->setCancelled(true);
             } else {
                 $event->getPlayer()->sendMessage(TextFormat::GREEN . "Free sign successfully created!");
                 $event->setLine(0, TextFormat::AQUA . "[Free]");
                 $event->setLine(1, $item->getName() === "Unknown" ? $item->getID() : $item->getName());
                 $event->setLine(2, $damage);
             }
         } else {
             $event->getPlayer()->sendMessage(TextFormat::RED . "[Error] You should provide an item name/ID");
             $event->setCancelled(true);
         }
     } elseif (strtolower(TextFormat::clean($event->getLine(0), true)) === "[gamemode]" && $event->getPlayer()->hasPermission("essentials.sign.create.gamemode")) {
         switch (strtolower($event->getLine(1))) {
             case "survival":
             case "0":
                 $event->setLine(1, "Survival");
                 break;
             case "creative":
             case "1":
                 $event->setLine(1, "Creative");
                 break;
             case "adventure":
             case "2":
                 $event->setLine(1, "Adventure");
                 break;
             case "spectator":
             case "view":
             case "3":
                 $event->setLine(1, "Spectator");
                 break;
             default:
                 $event->getPlayer()->sendMessage(TextFormat::RED . "[Error] Unknown Gamemode, you should use \"Survival\", \"Creative\", \"Adventure\" or \"Spectator\"");
                 $event->setCancelled(true);
                 return;
                 break;
         }
         $event->getPlayer()->sendMessage(TextFormat::GREEN . "Gamemode sign successfully created!");
         $event->setLine(0, TextFormat::AQUA . "[Gamemode]");
     } elseif (strtolower(TextFormat::clean($event->getLine(0), true)) === "[heal]" && $event->getPlayer()->hasPermission("essentials.sign.create.heal")) {
         $event->getPlayer()->sendMessage(TextFormat::GREEN . "Heal sign successfully created!");
         $event->setLine(0, TextFormat::AQUA . "[Heal]");
     } elseif (strtolower(TextFormat::clean($event->getLine(0), true)) === "[kit]" && $event->getPlayer()->hasPermission("essentials.sign.create.kit")) {
         if (!$this->getAPI()->kitExists($event->getLine(1))) {
             $event->getPlayer()->sendMessage(TextFormat::RED . "[Error] Kit doesn't exist");
             return;
         }
         $event->getPlayer()->sendMessage(TextFormat::GREEN . "Kit sign successfully created!");
         $event->setLine(0, TextFormat::AQUA . "[Kit]");
     } elseif (strtolower(TextFormat::clean($event->getLine(0), true)) === "[repair]" && $event->getPlayer()->hasPermission("essentials.sign.create.repair")) {
         switch (strtolower($event->getLine(1))) {
             case "hand":
                 $event->setLine(1, "Hand");
                 break;
             case "all":
                 $event->setLine(1, "All");
                 break;
             default:
                 $event->getPlayer()->sendMessage(TextFormat::RED . "[Error] Invalid argument, you should use \"Hand\" or \"All\"");
                 $event->setCancelled(true);
                 return;
                 break;
         }
         $event->getPlayer()->sendMessage(TextFormat::GREEN . "Repair sign successfully created!");
         $event->setLine(0, TextFormat::AQUA . "[Repair]");
     } elseif (strtolower(TextFormat::clean($event->getLine(0), true)) === "[time]" && $event->getPlayer()->hasPermission("essentials.sign.create.time")) {
         switch (strtolower($event->getLine(1))) {
             case "day":
                 $event->setLine(1, "Day");
                 break;
             case "night":
                 $event->setLine(1, "Night");
                 break;
             default:
                 $event->getPlayer()->sendMessage(TextFormat::RED . "[Error] Invalid time, you should use \"Day\" or \"Night\"");
                 $event->setCancelled(true);
                 return;
                 break;
         }
         $event->getPlayer()->sendMessage(TextFormat::GREEN . "Time sign successfully created!");
         $event->setLine(0, TextFormat::AQUA . "[Time]");
     } elseif (strtolower(TextFormat::clean($event->getLine(0), true)) === "[teleport]" && $event->getPlayer()->hasPermission("essentials.sign.create.teleport")) {
         if (!is_numeric($event->getLine(1))) {
//.........这里部分代码省略.........
开发者ID:PrimusLV,项目名称:EssentialsPE,代码行数:101,代码来源:SignEvents.php

示例11: handleDataPacket


//.........这里部分代码省略.........
             $target = $this->level->getEntity($packet->target);
             $cancelled = false;
             if ($target instanceof Player and $this->server->getConfigBoolean("pvp", true) === false) {
                 $cancelled = true;
             }
             if ($target instanceof Entity and $this->getGamemode() !== Player::VIEW and $this->dead !== true and $target->dead !== true) {
                 if ($target instanceof DroppedItem or $target instanceof Arrow) {
                     $this->kick("Attempting to attack an invalid entity");
                     $this->server->getLogger()->warning("Player " . $this->getName() . " tried to attack an invalid entity");
                     return;
                 }
                 $item = $this->inventory->getItemInHand();
                 $damageTable = [Item::WOODEN_SWORD => 4, Item::GOLD_SWORD => 4, Item::STONE_SWORD => 5, Item::IRON_SWORD => 6, Item::DIAMOND_SWORD => 7, Item::WOODEN_AXE => 3, Item::GOLD_AXE => 3, Item::STONE_AXE => 3, Item::IRON_AXE => 5, Item::DIAMOND_AXE => 6, Item::WOODEN_PICKAXE => 2, Item::GOLD_PICKAXE => 2, Item::STONE_PICKAXE => 3, Item::IRON_PICKAXE => 4, Item::DIAMOND_PICKAXE => 5, Item::WOODEN_SHOVEL => 1, Item::GOLD_SHOVEL => 1, Item::STONE_SHOVEL => 2, Item::IRON_SHOVEL => 3, Item::DIAMOND_SHOVEL => 4];
                 $damage = [EntityDamageEvent::MODIFIER_BASE => isset($damageTable[$item->getId()]) ? $damageTable[$item->getId()] : 1];
                 if ($this->distance($target) > 8) {
                     $cancelled = true;
                 } elseif ($target instanceof Player) {
                     if (($target->getGamemode() & 0x1) > 0) {
                         break;
                     } elseif ($this->server->getConfigBoolean("pvp") !== true or $this->server->getDifficulty() === 0) {
                         $cancelled = true;
                     }
                     $armorValues = [Item::LEATHER_CAP => 1, Item::LEATHER_TUNIC => 3, Item::LEATHER_PANTS => 2, Item::LEATHER_BOOTS => 1, Item::CHAIN_HELMET => 1, Item::CHAIN_CHESTPLATE => 5, Item::CHAIN_LEGGINGS => 4, Item::CHAIN_BOOTS => 1, Item::GOLD_HELMET => 1, Item::GOLD_CHESTPLATE => 5, Item::GOLD_LEGGINGS => 3, Item::GOLD_BOOTS => 1, Item::IRON_HELMET => 2, Item::IRON_CHESTPLATE => 6, Item::IRON_LEGGINGS => 5, Item::IRON_BOOTS => 2, Item::DIAMOND_HELMET => 3, Item::DIAMOND_CHESTPLATE => 8, Item::DIAMOND_LEGGINGS => 6, Item::DIAMOND_BOOTS => 3];
                     $points = 0;
                     foreach ($target->getInventory()->getArmorContents() as $index => $i) {
                         if (isset($armorValues[$i->getId()])) {
                             $points += $armorValues[$i->getId()];
                         }
                     }
                     $damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
                 }
                 $ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage);
                 if ($cancelled) {
                     $ev->setCancelled();
                 }
                 $target->attack($ev->getFinalDamage(), $ev);
                 if ($ev->isCancelled()) {
                     if ($item->isTool() and $this->isSurvival()) {
                         $this->inventory->sendContents($this);
                     }
                     break;
                 }
                 if ($item->isTool() and $this->isSurvival()) {
                     if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
                         $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1), $this);
                     } else {
                         $this->inventory->setItemInHand($item, $this);
                     }
                 }
             }
             break;
         case ProtocolInfo::ANIMATE_PACKET:
             if ($this->spawned === false or $this->dead === true) {
                 break;
             }
             $this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
             if ($ev->isCancelled()) {
                 break;
             }
             $pk = new AnimatePacket();
             $pk->eid = $this->getId();
             $pk->action = $ev->getAnimationType();
             Server::broadcastPacket($this->getViewers(), $pk);
             break;
         case ProtocolInfo::RESPAWN_PACKET:
             if ($this->spawned === false or $this->dead === false) {
开发者ID:rryy,项目名称:PocketMine-MP,代码行数:67,代码来源:Player.php

示例12: onSignChangeEvent

 /**
  * 표지판으로 태그블럭을 설치가능하게 이벤트처리
  *
  * @param SignChangeEvent $event        	
  */
 public function onSignChangeEvent(SignChangeEvent $event)
 {
     if (!$event->getPlayer()->hasPermission("tagblock.add")) {
         return;
     }
     if (strtolower($event->getLine(0)) != $this->db->get("TAGBlock-line0")) {
         return;
     }
     if ($event->getLine(1) != null) {
         $message = $event->getLine(1);
     }
     if ($event->getLine(2) != null) {
         $message .= "\n" . $event->getLine(2);
     }
     if ($event->getLine(3) != null) {
         $message .= "\n" . $event->getLine(3);
     }
     $block = $event->getBlock()->getSide(0);
     $blockPos = "{$block->x}.{$block->y}.{$block->z}";
     $this->db->db["TAGBlock"][$block->getLevel()->getFolderName()][$blockPos] = $message;
     $this->db->message($event->getPlayer(), $this->db->get("TAGBlock-added"));
     $event->setCancelled();
     $event->getBlock()->getLevel()->setBlock($event->getBlock(), Block::get(Block::AIR));
 }
开发者ID:wsj7178,项目名称:TAGBlock,代码行数:29,代码来源:TAGBlock.php

示例13: handleDataPacket


//.........这里部分代码省略.........
                         $this->lastBreak = microtime(true);
                     } else {
                         $this->inventory->sendHeldItem($this);
                     }
                     break;
                 case PlayerActionPacket::ACTION_ABORT_BREAK:
                     $this->lastBreak = PHP_INT_MAX;
                     break;
                 case PlayerActionPacket::ACTION_RELEASE_ITEM:
                     if ($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)) {
                         if ($this->inventory->getItemInHand()->getId() === Item::BOW) {
                             $bow = $this->inventory->getItemInHand();
                             if ($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, null))) {
                                 $this->inventory->sendContents($this);
                                 break;
                             }
                             $arrow = false;
                             foreach ($this->inventory->getContents() as $item) {
                                 if ($item->getId() == Item::ARROW) {
                                     $arrow = $item;
                                 }
                             }
                             if ($arrow === false and $this->isCreative()) {
                                 $arrow = Item::get(Item::ARROW, 0, 1);
                             } elseif ($arrow === false) {
                                 break;
                             }
                             $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)]), "Fire" => new ShortTag("Fire", $this->isOnFire() ? 45 * 60 : 0), "Potion" => new ShortTag("Potion", $arrow->getDamage())]);
                             $diff = $this->server->getTick() - $this->startAction;
                             $p = $diff / 20;
                             $f = min(($p ** 2 + $p * 2) / 3, 1) * 2;
                             $ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f);
                             if ($f < 0.1 or $diff < 5) {
                                 $ev->setCancelled();
                             }
                             $this->server->getPluginManager()->callEvent($ev);
                             if ($ev->isCancelled()) {
                                 $ev->getProjectile()->kill();
                                 $this->inventory->sendContents($this);
                             } else {
                                 $ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
                                 if ($this->isSurvival()) {
                                     $this->inventory->removeItem(Item::get(Item::ARROW, $arrow->getDamage(), 1));
                                     $bow->setDamage($bow->getDamage() + 1);
                                     if ($bow->getDamage() >= 385) {
                                         $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0));
                                     } else {
                                         $this->inventory->setItemInHand($bow);
                                     }
                                 }
                                 if ($ev->getProjectile() instanceof Projectile) {
                                     $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
                                     if ($projectileEv->isCancelled()) {
                                         $ev->getProjectile()->kill();
                                     } else {
                                         $ev->getProjectile()->spawnToAll();
                                         $this->level->addSound(new LaunchSound($this), $this->getViewers());
                                     }
                                 } else {
                                     $ev->getProjectile()->spawnToAll();
                                 }
                             }
                         }
                     } elseif ($this->inventory->getItemInHand()->getId() === Item::BUCKET and $this->inventory->getItemInHand()->getDamage() === 1) {
                         //Milk!
                         $this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $this->inventory->getItemInHand()));
开发者ID:yungtechboy1,项目名称:Genisys,代码行数:67,代码来源:Player.php

示例14: signPlace

 public function signPlace(SignChangeEvent $event)
 {
     if ($event->getPlayer()->isOp()) {
         return;
     }
     $message = "";
     foreach ($event->getLines() as $line) {
         $message .= $line . "\n";
     }
     if (!isset($this->signCheck[$event->getPlayer()->getName() . ">" . $message])) {
         $this->signCheck[$event->getPlayer()->getName() . ">" . $message] = false;
         $blockPos = "{$event->getBlock()->x}:{$event->getBlock()->y}:{$event->getBlock()->z}";
         $this->getServer()->getScheduler()->scheduleAsyncTask(new GentlemanAsyncTask($event->getPlayer()->getName(), [$event->getBlock()->getId(), $event->getBlock()->getDamage(), $blockPos], $message, $this->badQueue, $this->dictionary, "sign", true));
         $event->setCancelled();
         return;
     } else {
         if (!$this->signCheck[$event->getPlayer()->getName() . ">" . $message]) {
             $event->setCancelled();
             return;
         } else {
             unset($this->signCheck[$event->getPlayer()->getName() . ">" . $message]);
         }
     }
 }
开发者ID:nesgohood,项目名称:PMMP-Plugins,代码行数:24,代码来源:Gentleman.php

示例15: handleDataPacket


//.........这里部分代码省略.........
                         $this->lastBreak = microtime(true);
                     } else {
                         $this->inventory->sendHeldItem($this);
                     }
                     break;
                 case PlayerActionPacket::ACTION_ABORT_BREAK:
                     $this->lastBreak = PHP_INT_MAX;
                     break;
                 case PlayerActionPacket::ACTION_RELEASE_ITEM:
                     if ($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)) {
                         if ($this->inventory->getItemInHand()->getId() === Item::BOW) {
                             $bow = $this->inventory->getItemInHand();
                             if ($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, null))) {
                                 $this->inventory->sendContents($this);
                                 break;
                             }
                             $arrow = false;
                             foreach ($this->inventory->getContents() as $item) {
                                 if ($item->getId() == Item::ARROW) {
                                     $arrow = $item;
                                 }
                             }
                             if ($arrow === false and $this->isCreative()) {
                                 $arrow = Item::get(Item::ARROW, 0, 1);
                             } elseif ($arrow === false) {
                                 break;
                             }
                             $nbt = new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $this->x), new DoubleTag("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->z)]), "Motion" => new ListTag("Motion", [new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $this->yaw), new FloatTag("", $this->pitch)]), "Fire" => new ShortTag("Fire", $this->isOnFire() ? 45 * 60 : 0), "Potion" => new ShortTag("Potion", $arrow->getDamage())]);
                             $diff = $this->server->getTick() - $this->startAction;
                             $p = $diff / 20;
                             $f = min(($p ** 2 + $p * 2) / 3, 1) * 2;
                             $ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f);
                             if ($f < 0.1 or $diff < 5) {
                                 $ev->setCancelled();
                             }
                             $this->server->getPluginManager()->callEvent($ev);
                             if ($ev->isCancelled()) {
                                 $ev->getProjectile()->kill();
                                 $this->inventory->sendContents($this);
                             } else {
                                 $ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce()));
                                 if ($this->isSurvival()) {
                                     $this->inventory->removeItem(Item::get(Item::ARROW, $arrow->getDamage(), 1));
                                     $bow->setDamage($bow->getDamage() + 1);
                                     if ($bow->getDamage() >= 385) {
                                         $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0));
                                     } else {
                                         $this->inventory->setItemInHand($bow);
                                     }
                                 }
                                 if ($ev->getProjectile() instanceof Projectile) {
                                     $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile()));
                                     if ($projectileEv->isCancelled()) {
                                         $ev->getProjectile()->kill();
                                     } else {
                                         $ev->getProjectile()->spawnToAll();
                                         $this->level->addSound(new LaunchSound($this), $this->getViewers());
                                     }
                                 } else {
                                     $ev->getProjectile()->spawnToAll();
                                 }
                             }
                         }
                     } elseif ($this->inventory->getItemInHand()->getId() === Item::BUCKET and $this->inventory->getItemInHand()->getDamage() === 1) {
                         //Milk!
                         $this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $this->inventory->getItemInHand()));
开发者ID:iTXTech,项目名称:Genisys,代码行数:67,代码来源:Player.php


注:本文中的pocketmine\event\block\SignChangeEvent::setCancelled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。