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


PHP Effect::getEffectByName方法代码示例

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


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

示例1: parseEffectLine

 private function parseEffectLine($txt)
 {
     $txt = preg_split('/\\s*:\\s*/', $txt);
     if (count($txt) == 0 || count($txt) > 3) {
         return null;
     }
     if (!isset($txt[1]) || empty($txt[1])) {
         $txt[1] = 60;
     }
     if (!isset($txt[2]) || empty($txt[2])) {
         $txt[2] = 1;
     }
     if (is_numeric($txt[0])) {
         $effect = Effect::getEffect($txt[0]);
     } else {
         $effect = Effect::getEffectByName($txt[0]);
     }
     if ($effect === null) {
         return null;
     }
     $effect->setDuration($txt[1] * 20);
     $effect->setAmplifier($txt[2]);
     $effect->setVisible(true);
     return $effect;
 }
开发者ID:DWWf,项目名称:pocketmine-plugins,代码行数:25,代码来源:SignMgr.php

示例2: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return \true;
     }
     if (\count($args) < 2) {
         return \true;
     }
     $player = $sender->getServer()->getPlayer($args[0]);
     if ($player === \null) {
         return \true;
     }
     if (\strtolower($args[1]) === "clear") {
         foreach ($player->getEffects() as $effect) {
             $player->removeEffect($effect->getId());
         }
         return \true;
     }
     $effect = Effect::getEffectByName($args[1]);
     if ($effect === \null) {
         $effect = Effect::getEffect((int) $args[1]);
     }
     if ($effect === \null) {
         return \true;
     }
     $duration = 300;
     $amplification = 0;
     if (\count($args) >= 3) {
         $duration = (int) $args[2];
         if (!$effect instanceof InstantEffect) {
             $duration *= 20;
         }
     } elseif ($effect instanceof InstantEffect) {
         $duration = 1;
     }
     if (\count($args) >= 4) {
         $amplification = (int) $args[3];
     }
     if (\count($args) >= 5) {
         $v = \strtolower($args[4]);
         if ($v === "on" or $v === "true" or $v === "t" or $v === "1") {
             $effect->setVisible(\false);
         }
     }
     if ($duration === 0) {
         if (!$player->hasEffect($effect->getId())) {
             if (\count($player->getEffects()) === 0) {
             } else {
             }
             return \true;
         }
         $player->removeEffect($effect->getId());
     } else {
         $effect->setDuration($duration)->setAmplifier($amplification);
         $player->addEffect($effect);
     }
     return \true;
 }
开发者ID:Edwardthedog2,项目名称:Steadfast2,代码行数:58,代码来源:EffectCommand.php

示例3: execute

 public function execute(CommandSender $sender, $currentAlias, array $args)
 {
     if (!$this->testPermission($sender)) {
         return true;
     }
     if (count($args) < 2) {
         $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage]));
         return true;
     }
     $player = $sender->getServer()->getPlayer($args[0]);
     if ($player === null) {
         $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.player.notFound"));
         return true;
     }
     if (strtolower($args[1]) === "clear") {
         foreach ($player->getEffects() as $effect) {
             $player->removeEffect($effect->getId());
         }
         $sender->sendMessage(new TranslationContainer("commands.effect.success.removed.all", [$player->getDisplayName()]));
         return true;
     }
     $effect = Effect::getEffectByName($args[1]);
     if ($effect === null) {
         $effect = Effect::getEffect((int) $args[1]);
     }
     if ($effect === null) {
         $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.effect.notFound", [(string) $args[1]]));
         return true;
     }
     $duration = 300;
     $amplification = 0;
     if (count($args) >= 3) {
         $duration = (int) $args[2];
         if (!$effect instanceof InstantEffect) {
             $duration *= 20;
         }
     } elseif ($effect instanceof InstantEffect) {
         $duration = 1;
     }
     if (count($args) >= 4) {
         $amplification = (int) $args[3];
     }
     if (count($args) >= 5) {
         $v = strtolower($args[4]);
         if ($v === "on" or $v === "true" or $v === "t" or $v === "1") {
             $effect->setVisible(false);
         }
     }
     if ($duration === 0) {
         if (!$player->hasEffect($effect->getId())) {
             if (count($player->getEffects()) === 0) {
                 $sender->sendMessage(new TranslationContainer("commands.effect.failure.notActive.all", [$player->getDisplayName()]));
             } else {
                 $sender->sendMessage(new TranslationContainer("commands.effect.failure.notActive", [$effect->getName(), $player->getDisplayName()]));
             }
             return true;
         }
         $player->removeEffect($effect->getId());
         $sender->sendMessage(new TranslationContainer("commands.effect.success.removed", [$effect->getName(), $player->getDisplayName()]));
     } else {
         $effect->setDuration($duration)->setAmplifier($amplification);
         $player->addEffect($effect);
         self::broadcastCommandMessage($sender, new TranslationContainer("%commands.effect.success", [$effect->getName(), $effect->getId(), $effect->getAmplifier(), $player->getDisplayName(), $effect->getDuration() / 20]));
     }
     return true;
 }
开发者ID:TexusDark,项目名称:Ananas-MP,代码行数:66,代码来源:EffectCommand.php

示例4: blockBreak


//.........这里部分代码省略.........
                                 for ($z = $pos->z - 1; $z <= $pos->z + 1; $z++) {
                                     if (!($x === $pos->x && $z === $pos->z)) {
                                         for ($y = $pos->y; $y <= $pos->y + 2; $y++) {
                                             $player->getLevel()->setBlock(new Position($x, $y, $z, $pos->getLevel()), new Block(Block::IRON_BAR));
                                         }
                                     }
                                 }
                             }
                             break;
                         case 4:
                             $arr = [["x" => -1, "y" => -1, "z" => -1, "block" => Block::OBSIDIAN], ["x" => -1, "y" => -1, "z" => 0, "block" => Block::OBSIDIAN], ["x" => -1, "y" => -1, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 0, "y" => -1, "z" => -1, "block" => Block::OBSIDIAN], ["x" => 0, "y" => -1, "z" => 0, "block" => Block::OBSIDIAN], ["x" => 0, "y" => -1, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => -1, "z" => -1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => -1, "z" => 0, "block" => Block::OBSIDIAN], ["x" => 1, "y" => -1, "z" => 1, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 0, "z" => -1, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 0, "z" => 0, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 0, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 0, "y" => 0, "z" => -1, "block" => Block::OBSIDIAN], ["x" => 0, "y" => 0, "z" => 0, "block" => Block::STILL_WATER], ["x" => 0, "y" => 0, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 0, "z" => -1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 0, "z" => 0, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 0, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 0, "z" => 1, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 1, "z" => -1, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 1, "z" => 0, "block" => Block::GLASS], ["x" => -1, "y" => 1, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 0, "y" => 1, "z" => -1, "block" => Block::GLASS], ["x" => 0, "y" => 1, "z" => 0, "block" => Block::STILL_WATER], ["x" => 0, "y" => 1, "z" => 1, "block" => Block::GLASS], ["x" => 1, "y" => 1, "z" => -1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 1, "z" => 0, "block" => Block::GLASS], ["x" => 1, "y" => 1, "z" => 1, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 2, "z" => -1, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 2, "z" => 0, "block" => Block::OBSIDIAN], ["x" => -1, "y" => 2, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 0, "y" => 2, "z" => -1, "block" => Block::OBSIDIAN], ["x" => 0, "y" => 2, "z" => 0, "block" => Block::OBSIDIAN], ["x" => 0, "y" => 2, "z" => 1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 2, "z" => -1, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 2, "z" => 0, "block" => Block::OBSIDIAN], ["x" => 1, "y" => 2, "z" => 1, "block" => Block::OBSIDIAN]];
                             break;
                         case 5:
                             $arr = [["x" => -1, "y" => 0, "z" => -1, "block" => Block::STILL_LAVA], ["x" => -1, "y" => 0, "z" => 0, "block" => Block::STILL_LAVA], ["x" => -1, "y" => 0, "z" => 1, "block" => Block::STILL_LAVA], ["x" => 0, "y" => 0, "z" => -1, "block" => Block::STILL_LAVA], ["x" => 0, "y" => 0, "z" => 0, "block" => Block::STILL_LAVA], ["x" => 0, "y" => 0, "z" => 1, "block" => Block::STILL_LAVA], ["x" => 1, "y" => 0, "z" => -1, "block" => Block::STILL_LAVA], ["x" => 1, "y" => 0, "z" => 0, "block" => Block::STILL_LAVA], ["x" => 1, "y" => 0, "z" => 1, "block" => Block::STILL_LAVA], ["x" => -1, "y" => 1, "z" => -1, "block" => Block::COBWEB], ["x" => -1, "y" => 1, "z" => 0, "block" => Block::COBWEB], ["x" => -1, "y" => 1, "z" => 1, "block" => Block::COBWEB], ["x" => 0, "y" => 1, "z" => -1, "block" => Block::COBWEB], ["x" => 0, "y" => 1, "z" => 0, "block" => Block::COBWEB], ["x" => 0, "y" => 1, "z" => 1, "block" => Block::COBWEB], ["x" => 1, "y" => 1, "z" => -1, "block" => Block::COBWEB], ["x" => 1, "y" => 1, "z" => 0, "block" => Block::COBWEB], ["x" => 1, "y" => 1, "z" => 1, "block" => Block::COBWEB]];
                             break;
                     }
                     $pos = $player->getPosition();
                     foreach ($arr as $i => $c) {
                         $player->getLevel()->setBlock($pos->add($c["x"], $c["y"], $c["z"]), Block::get($c["block"]), true, true);
                     }
                     break;
                 }
             case 6:
                 if (!isset($this->data["functions"]["chest"]) || $this->data["functions"]["chest"]) {
                     $player->getLevel()->setBlock($block, new Block(Block::CHEST), true, true);
                     $nbt = new CompoundTag("", [new ListTag("Items", []), new StringTag("id", Tile::CHEST), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z)]);
                     $nbt->Items->setTagType(NBT::TAG_Compound);
                     $tile = Tile::createTile("Chest", $block->getLevel()->getChunk($block->x >> 4, $block->z >> 4), $nbt);
                     if ($tile instanceof Chest) {
                         for ($i = 0; $i <= mt_rand(1, $this->data["max_chest_item"]); $i++) {
                             if (count($this->data["items_dropped"]) === 0) {
                                 $item = $this->randItem();
                             } else {
                                 $item = $this->data["items_dropped"][mt_rand(0, count($this->data["items_dropped"]) - 1)];
                             }
                             $tile->getInventory()->setItem($i, $item);
                         }
                         $player->sendMessage($this->tag . $this->message->get("chest"));
                     }
                     break;
                 }
             case 7:
                 if (!isset($this->data["functions"]["teleport"]) || $this->data["functions"]["teleport"]) {
                     $player->teleport($player->getLevel()->getSpawnLocation(), $player->getYaw(), $player->getPitch());
                     $player->sendMessage($this->tag . $this->message->get("spawn"));
                     break;
                 }
             case 8:
                 if (!isset($this->data["functions"]["potion"]) || $this->data["functions"]["potion"]) {
                     if (count($this->data["potions"])) {
                         $effect = Effect::getEffectByName($this->data["potions"][$rand->nextRange(0, count($this->data["potions"]) - 1)]);
                         $effect->setDuration($rand->nextRange(20, $this->data["max_duration"] * 20));
                         $player->addEffect($effect);
                         $player->sendMessage($this->tag . $this->message->get("effect"));
                     } else {
                         $player->sendMessage($this->tag . $this->message->get("unlucky"));
                     }
                     break;
                 }
             case 9:
                 //exec command
                 if (!isset($this->data["functions"]["execCmd"]) || $this->data["functions"]["execCmd"]) {
                     if (count($this->data["commands"])) {
                         $cmd = $this->data["commands"][$rand->nextRange(0, count($this->data["commands"]) - 1)];
                         $cmd = str_replace(["%PLAYER%", "%X%", "%Y%", "%Z%", "%WORLD%", "%IP%", "%XP%"], [$player->getName(), $player->getX(), $player->getY(), $player->getZ(), $player->getLevel()->getName(), $player->getAddress(), $player->getXpLevel()], $cmd);
                         $this->getServer()->dispatchCommand(new ConsoleCommandSender(), $cmd);
                         $player->sendMessage($this->tag . $this->message->get("command"));
                         break;
                     }
                 }
             case 10:
                 //mob
                 if (!isset($this->data["functions"]["mob"]) || $this->data["functions"]["mob"]) {
                     if (count($this->data["mob"])) {
                         $mob = $this->data["mob"][$rand->nextRange(0, count($this->data["mob"]) - 1)];
                         if ($this->isExistsEntity($mob)) {
                             $nbt = new CompoundTag("", [new ListTag("Pos", [new DoubleTag("", $block->getX()), new DoubleTag("", $block->getY()), new DoubleTag("", $block->getZ())]), new ListTag("Rotation", [new FloatTag("", $player->getYaw()), new FloatTag("", $player->getPitch())]), new StringTag("CustomName", $this->tag)]);
                             $entity = Entity::createEntity($mob, $player->getLevel()->getChunk($block->getX() >> 4, $block->getZ() >> 4), $nbt);
                             if ($entity instanceof Entity) {
                                 $entity->spawnToAll();
                                 $this->getServer()->getScheduler()->scheduleDelayedTask(new TaskExplodeMob($this, $entity, mt_rand($this->data["explosion_min"], $this->data["explosion_max"])), 20 * mt_rand(1, $this->data["mob_explosion_delay"]));
                                 $player->sendMessage($this->tag . $this->message->get("mob"));
                                 break;
                             }
                         }
                     }
                 }
             case 11:
                 if (!isset($this->data["functions"]["lightning"]) || $this->data["functions"]["lightning"]) {
                     $player->getLevel()->spawnLightning($player);
                     $player->sendMessage($this->tag . $this->message->get("lightning"));
                     break;
                 }
             case 12:
                 $player->sendMessage($this->tag . $this->message->get("unlucky"));
                 break;
         }
         $player->getLevel()->save();
     }
 }
开发者ID:xionbig,项目名称:LuckyBlock,代码行数:101,代码来源:Main.php

示例5: onSignChange

 public function onSignChange(SignChangeEvent $event)
 {
     if (!$event->getPlayer()->hasPermission("potiondispenser.create")) {
         return;
     }
     $text = $event->getLines();
     $prefix = strtoupper($text[0]);
     if ($prefix !== "[DISPENSER]" && $prefix !== "[POTION SHOP]") {
         return;
     }
     $effect = explode(':', $text[1] . $text[2]);
     if (count($effect) < 1) {
         return;
     }
     if ($effect[0] === "clear") {
         $this->registerDispenser(array("name" => "clear", "cost" => (int) $text[3]), $event->getBlock(), $event->getPlayer());
         $event->setLine(0, $this->getTranslation("DISPENSER"));
         $event->setLine(1, TextFormat::GOLD . $this->getTranslation("POTION_NAME_NO_LEV", $this->getTranslation("CLEAR")));
         $event->setLine(2, "");
         $event->setLine(3, $this->getTranslation("DISPENSER_COST", (int) $text[3] . EconomyAPI::getInstance()->getMonetaryUnit()));
         return;
     } elseif (count($effect) < 2) {
         return;
     }
     $effectInstance = Effect::getEffectByName($effect[0]);
     if ($effectInstance === null) {
         $effectInstance = Effect::getEffect($effect[0]);
         if ($effectInstance === null) {
             return;
         }
     }
     $effectId = $effectInstance->getId();
     $amplifier = (int) $effect[1];
     if ($effectInstance instanceof InstantEffect) {
         $duration = 1;
     } else {
         if (count($effect) < 3) {
             return;
         }
         $duration = (int) $effect[2] * 20;
     }
     $this->registerDispenser(array("name" => $effectId, "amplifier" => $amplifier, "duration" => $duration, "cost" => $text[3]), $event->getBlock(), $event->getPlayer());
     $event->setLine(0, $this->getTranslation("DISPENSER"));
     $color = $effectInstance->isBad() ? TextFormat::RED : TextFormat::AQUA;
     $event->setLine(1, $color . $this->getTranslation("POTION_NAME", $this->getServer()->getLanguage()->translate(new TextContainer($effectInstance->getName())), $amplifier + 1));
     if ($effectInstance instanceof InstantEffect) {
         $event->setLine(2, "");
     } else {
         $event->setLine(2, $this->getTranslation("DURATION", (int) $effect[2]));
     }
     $price = (int) $text[3] . EconomyAPI::getInstance()->getMonetaryUnit();
     $event->setLine(3, $this->getTranslation("DISPENSER_COST", $price));
 }
开发者ID:sJimin,项目名称:EconomyPotionShop,代码行数:53,代码来源:Dispenser.php

示例6: Buy

 public function Buy($Player, $Menu, $Slot)
 {
     if (!isset($this->plugin->Buys_Values[$Menu][1][$Slot])) {
         return true;
     }
     $BuyData = $this->plugin->Buys_Values[$Menu][1][$Slot];
     if ($this->PopupInfo2->PlayersData[strtolower($Player->getName())][1] >= $BuyData[0]) {
         switch ($BuyData[4]) {
             case 0:
                 $Item = Item::fromString($BuyData[1] . ":" . $BuyData[2]);
                 $Item->setCount($BuyData[3]);
                 if ($Player->getInventory()->canAddItem($Item)) {
                     $Player->getInventory()->addItem(clone $Item);
                     $this->PopupInfo2->PlayersData[strtolower($Player->getName())][1] -= $BuyData[0];
                 } else {
                     $Player->sendPopup($this->plugin->getMessage("bedwars.buy.inv_full"));
                 }
                 break;
             case 1:
                 if (($Effect = Effect::getEffectByName($BuyData[5])) == null && ($Effect = Effect::getEffect($BuyData[5])) == null) {
                     return;
                 }
                 $Effect->setDuration($BuyData[6] * 20);
                 $Effect->setAmplifier($BuyData[7]);
                 $Player->addEffect($Effect);
                 $this->PopupInfo2->PlayersData[strtolower($Player->getName())][1] -= $BuyData[0];
                 break;
         }
     } else {
         $Player->sendPopup($this->plugin->getMessage("bedwars.buy.no_money"));
     }
     return true;
 }
开发者ID:SuperAdam47,项目名称:BedWarsPE,代码行数:33,代码来源:BedWars.php

示例7: addEffect

 /**
  * /effect <player> <effect> [seconds] [amplifier] [hideParticles]
  *
  * @param Player $player
  * @param        $effectType
  * @param int    $duration
  * @param int    $amplification
  * @param bool   $hiderParticles
  * @return true
  */
 public static function addEffect(Player $player, $effectType, $duration = 300, $amplification = 0, $hiderParticles = false)
 {
     $effect = Effect::getEffectByName($effectType);
     if ($effect === null) {
         $effect = Effect::getEffect((int) $effectType);
     }
     // $duration = 300;
     $amplification = 0;
     if ($hiderParticles) {
         $effect->setVisible(\false);
     }
     $effect->setDuration($duration)->setAmplifier($amplification);
     $player->addEffect($effect);
     return $effect;
 }
开发者ID:robozeri,项目名称:SG,代码行数:25,代码来源:MagicUtil.php

示例8: onBlockBreak

 public function onBlockBreak(PlayerInteractEvent $event)
 {
     if ($event->getPlayer() instanceof Player && $this->isPlaying($event->getPlayer())) {
         // effect if in config
         if ($this->getConfig()->exists("blocks." . $event->getBlock()->getName()) && $this->getConfig()->exists("blocks." . $event->getBlock()->getName() . ".effect")) {
             $effect = Effect::getEffectByName($this->getConfig()->getNested("blocks." . $event->getBlock()->getName() . ".effect"));
             if ($effect instanceof Effect) {
                 $effect->setDuration(200);
                 $effect->setVisible(false);
                 $event->getPlayer()->addEffect($effect);
             }
         }
         $event->getPlayer()->getLevel()->setBlock(new Vector3($event->getBlock()->getX(), $event->getBlock()->getY(), $event->getBlock()->getZ()), Block::get(0));
     }
 }
开发者ID:Edwardthedog2,项目名称:SpleefPE,代码行数:15,代码来源:Main.php

示例9: execute

 public function execute(CommandSender $sender, $label, array $args)
 {
     $label = "/" . $label . " ";
     if (!$sender->hasPermission("luckyblock.command")) {
         $sender->sendMessage($this->tag . TextFormat::RED . "You do not have permission to use this command!");
         return;
     }
     if (!isset($args) || !isset($args[0])) {
         $args[0] = "help";
     }
     $cmds = "";
     foreach ($args as $var) {
         $cmds = $cmds . "<" . $var . "> ";
     }
     $args[0] = strtolower($args[0]);
     $sender->sendMessage($this->tag . "Usage: " . TextFormat::DARK_AQUA . $label . $cmds);
     switch ($args[0]) {
         case "?":
         case "h":
         case "help":
             $var = ["on <none|function>", "off <none|function>", "list", "potion <add|rmv|list|duration> <effect>", "block <item>", "explosion <min|max|info>", "drop <add|rmv|list|max>", "world <allow|deny|list>", "command", "mob"];
             $message = "";
             foreach ($var as $c) {
                 $message .= $this->tag . TextFormat::WHITE . $label . $c . "\n";
             }
             $message .= $this->tag . TextFormat::GRAY . "Developed by" . TextFormat::BOLD . " @xionbig";
             $sender->sendMessage($message);
             return;
         case "effect":
         case "potion":
             if (!isset($args[1]) || empty($args[1])) {
                 $args[1] = "help";
             }
             switch ($args[1]) {
                 case "?":
                 case "h":
                 case "help":
                     $sender->sendMessage($this->tag . TextFormat::YELLOW . $label . TextFormat::WHITE . " potion " . TextFormat::YELLOW . " <add|rmv|list>");
                     return;
                 case "add":
                     if (!isset($args[2]) || empty($args[2])) {
                         $sender->sendMessage($this->tag . TextFormat::RED . "Invalid parameters.");
                         return;
                     }
                     if (Effect::getEffectByName($args[2]) instanceof Effect) {
                         if (!in_array($args[2], $this->data["potions"])) {
                             $arr = $this->setup->get("potions");
                             $arr[count($arr)] = $args[2];
                             $this->setup->set("potions", $arr);
                             $sender->sendMessage($this->tag . TextFormat::GREEN . "The potion '" . $args[2] . "' has been added successfully.");
                         } else {
                             $sender->sendMessage($this->tag . TextFormat::YELLOW . "The potion '" . $args[2] . "' is already present in the configuration.");
                         }
                     } else {
                         $sender->sendMessage($this->tag . TextFormat::RED . "The name of the potion is not valid");
                     }
                     break;
                 case "rmw":
                 case "rmv":
                 case "remove":
                     if (!isset($args[2]) || empty($args[2])) {
                         $sender->sendMessage($this->tag . TextFormat::RED . "Invalid parameters.");
                         return;
                     }
                     if (in_array($args[2], $this->data["potions"])) {
                         $it = [];
                         foreach ($this->data["potions"] as $i) {
                             if ($i !== $args[2]) {
                                 $it = $args[2];
                             }
                         }
                         $this->setup->set("potions", $it);
                         $sender->sendMessage($this->tag . TextFormat::GREEN . "The potion '" . $args[2] . "' has been successfully removed.");
                     } else {
                         $sender->sendMessage($this->tag . TextFormat::GREEN . "The potion '" . $args[2] . "' was not found in the configuration.");
                     }
                     break;
                 case "list":
                     $list = $this->tag . "List of potions enabled: ";
                     foreach ($this->data["potions"] as $potion) {
                         $list .= $potion . ", ";
                     }
                     $sender->sendMessage($list);
                     return;
                 case "duration":
                     if (!isset($args[2]) || empty($args[2]) || !is_numeric($args[2]) || $args[2] < 1) {
                         $sender->sendMessage($this->tag . TextFormat::RED . "Invalid parameters.");
                         return;
                     }
                     $this->setup->set("max_duration", $args[2]);
                     $sender->sendMessage($this->tag . TextFormat::GREEN . "The maximum duration of potion is set to " . $args[2]);
                     break;
             }
             $this->luckyBlock->reloadSetup($this->data);
             return;
         case "item":
         case "drop":
             if (!isset($args[1]) || empty($args[1])) {
                 $args[1] = "help";
             }
//.........这里部分代码省略.........
开发者ID:xionbig,项目名称:LuckyBlock,代码行数:101,代码来源:Commands.php


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