php pocketmine-entity-Effect类(方法)实例源码

下面列出了php pocketmine-entity-Effect 类(方法)源码代码实例,从而了解它的用法。

作者:jjplayin    项目:HotBloc   
public function onPlayerMove(PlayerMoveEvent $event)
 {
     $player = $event->getPlayer();
     $world = $player->getLevel();
     $block = $world->getBlock($player->floor()->subtract(0, 1));
     if ($world->getName() == $this->getHotBlock()->getConfig()->get("world")) {
         switch ($block->getId()) {
             case Block::PLANKS:
                 $player->sendTip("§aYou're safe!");
                 break;
             case Block::END_STONE:
                 $player->sendTip("§eGo!");
                 break;
             case Block::NETHERRACK:
                 $player->sendTip("§cYou'll poisoned!");
                 $effect = Effect::getEffect(Effect::POISON);
                 $effect->setVisible(true);
                 $effect->setDuration(50);
                 $player->addEffect($effect);
                 break;
             case Block::QUARTZ_BLOCK:
                 if (count($world->getPlayers()) < $this->getHotBlock()->getConfig()->get("players")) {
                     $player->sendTip("§cThere must be " . $this->getHotBlock()->getConfig()->get("players") . "players online");
                 } else {
                     $player->sendTip("§eYou're standing on the §l§cHot§6Block§r§e! §bMove!");
                     $this->getHotBlock()->getEconomy()->addMoney($player, 1, false, "HotBlock");
                     $player->sendPopup("§eYou have §a" . $this->getHotBlock()->getEconomy()->myMoney($player) . " §bCoins");
                 }
                 break;
         }
     }
 }

作者:Pab45    项目:SkyWorld_Serve   
public function onPlayerRespawned(PlayerRespawnEvent $event)
 {
     $p = $event->getPlayer();
     $level = $p->getLevel();
     $light = new AddEntityPacket();
     $light->type = 93;
     $light->eid = Entity::$entityCount++;
     $light->metadata = array();
     $light->speedX = 9;
     $light->speedY = 0;
     $light->speedZ = -9;
     $light->yaw = $p->getYaw();
     $light->pitch = $p->getPitch();
     $light->x = $p->x;
     $light->y = $p->y;
     $light->z = $p->z;
     foreach ($level->getPlayers() as $pl) {
         $pl->dataPacket($light);
         $pl->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(3)->setDuration(30000));
         $pl->setGamemode(2);
         $pl->getInventory()->addItem(new Item(Item::COOKIE, 0, 64));
         $pl->getInventory()->addItem(new Item(Item::SLIMEBALL, 0, 1));
         $pl->getInventory()->addItem(new Item(Item::COAL, 0, 1));
         $pl->getInventory()->addItem(new Item(Item::GUNPOWDER, 0, 1));
     }
 }

作者:PrimusL    项目:EssentialsP   
public function execute(CommandSender $sender, $alias, array $args)
 {
     if ($this->testPermission($sender)) {
         return false;
     }
     if (!$sender instanceof Player || count($args) < 1) {
         $this->sendUsage($sender, $alias);
         return false;
     }
     if (!is_numeric($args[0])) {
         $sender->sendMessage(TextFormat::RED . "[Error] Please provide a valid value");
         return false;
     }
     $player = $sender;
     if (isset($args[1]) && !($player = $this->getAPI()->getPlayer($args[1]))) {
         $sender->sendMessage(TextFormat::RED . "[Error] Player not found");
         return false;
     }
     if ((int) $args[0] === 0) {
         $player->removeEffect(Effect::SPEED);
     } else {
         $effect = Effect::getEffect(Effect::SPEED);
         $effect->setAmplifier($args[0]);
         $effect->setDuration(PHP_INT_MAX);
         $player->addEffect($effect);
     }
     $sender->sendMessage(TextFormat::YELLOW . "Speed amplified by " . TextFormat::WHITE . $args[0]);
     return true;
 }

作者:betausin    项目:Private-Plugin   
public function onPlayerDeathEvent(PlayerDeathEvent $event)
 {
     $cfg = $this->getConfig();
     $duration = $cfg->get("Duration");
     $particles = $cfg->get("Particles");
     $amplifier = $cfg->get("Amplifier");
     $give = $cfg->get("Add-Money");
     $lose = $cfg->get("Lost-Money");
     $id = $cfg->get("Effect-ID");
     $effect = Effect::getEffect($id);
     $effect->setVisible($particles);
     $effect->setAmplifier($amplifier);
     $effect->setDuration($duration);
     $player = $event->getEntity();
     $name = strtolower($player->getName());
     if ($player instanceof Player) {
         $cause = $player->getLastDamageCause();
         if ($cause instanceof EntityDamageByEntityEvent) {
             $damager = $cause->getDamager();
             if ($damager instanceof Player) {
                 $damager->sendMessage("You killed " . $player . ".\nYou earn \$" . $give . " for getting a kill and an effect!");
                 $damager->addEffect($effect);
                 $this->money->addMoney($damager, $give);
                 $player->sendMessage("You were killed by " . $damager);
                 $this->money->reduceMoney($player, $lose);
             }
         }
     }
 }

作者:DWW    项目:pocketmine-plugin   
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;
 }

作者:xHF    项目:SwordEffect   
public function onHurt(EntityDamageEvent $event)
 {
     if ($event instanceof EntityDamageByEntityEvent) {
         if ($event->getDamager()->getInventory()->getItemInHand()->getId() === 276) {
             $event->getEntity()->addEffect(Effect::getEffect($this->getConfig()->get("DiamondSwordEffect"))->setAmplifier($this->getConfig()->get("DiamondSwordAmp"))->setDuration($this->getConfig()->get("DiamondSwordTime"))->setVisible(false));
         }
     }
 }

作者:ItzFrozenCreepe    项目:Golden-Appl   
public function eat(PlayerItemConsumeEvent $ev)
 {
     $p = $ev->getPlayer();
     if ($ev->getItem()->getId() === 322) {
         $p->addEffect(Effect::getEffect(10)->setAmplifier(4)->setDuration(100)->setVisible(true));
         $p->addEffect(Effect::getEffect(21)->setAmplifier(2)->setDuration(20 * 120)->setVisible(true));
     }
 }

作者:Edwardthedog    项目:Steadfast   
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;
 }

作者:iTXTec    项目:Genisy   
public function getAdditionalEffects() : array
 {
     $chance = mt_rand(0, 100);
     if ($chance >= 20) {
         return [Effect::getEffect(Effect::HUNGER)->setDuration(30 * 20)];
     } else {
         return [];
     }
 }

作者:HelloWorld01    项目:SkyFal   
public function startGame()
 {
     $this->currentStatus = self::STATUS_PREPARING;
     $this->roundTick = 0;
     foreach ($this->player as $playerData) {
         $playerData["player"]->getInventory()->addItem(Item::get(self::SHOVEL));
         $playerData["player"]->addEffect(Effect::getEffect(Effect::JUMP)->setAmplifier(3)->setDuration(36000));
         $playerData["player"]->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(3)->setDuration(36000));
     }
 }

作者:EpicArtz0899    项目:Ezero   
public function onItemHeld(PlayerItemHeldEvent $ev)
 {
     $player = $ev->getPlayer();
     if ($ev->getPlayer()->getInventory()->getItemInHand()->getId() === 369) {
         $ev->getPlayer()->sendTip(TextFormat::RED . "Ezero Enabled!");
         $player->addEffect(Effect::getEffect(11)->setAmplifier(0)->setDuration(999999)->setVisible(false));
     } else {
         $player->removeEffect(11);
     }
 }

作者:BrokenLen    项目:PhpStormPlugi   
/**
  * @param PlayerInteractEvent $ev
  */
 public function onInteract(PlayerInteractEvent $ev)
 {
     if ($ev->getItem()->getId() == 296) {
         $player = $ev->getPlayer();
         $effect = Effect::getEffect(5);
         $effect->setDuration(20 * 1000);
         $effect->setAmplifier(1);
         $player->getEffect($effect);
         $effect1 = Effect::getEffect(4);
         $effect1->setDuration(20 * 1000);
         $effect1->setAmplifier(1);
         $player->getEffect($effect1);
     }
 }

作者:GmW    项目:PocketMine-MP-Plugin   
public function onMove(PlayerMoveEvent $event)
 {
     $bubble = new BubbleParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
     $critical = new CriticalParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
     $enchant = new EnchantParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
     $flame = new FlameParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
     $heart = new HeartParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
     $ink = new InkParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
     $lava = new LavaDripParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
     $portal = new PortalParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
     $smoke = new SmokeParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
     $water = new WaterDripParticle(new Vector3($event->getPlayer()->getX(), $event->getPlayer()->getY() + 0.5, $event->getPlayer()->getZ()));
     $player = $event->getPlayer();
     $cfg = $this->getConfig();
     $block = $event->getPlayer()->getLevel()->getBlock($event->getPlayer()->floor()->subtract(0, 1));
     if ($block instanceof Block) {
         $id = $block->getId();
         $meta = $block->getDamage();
         if ($cfg->exists($id . ":" . $meta)) {
             $effects = $cfg->get($id . ":" . $meta);
             foreach ($effects as $effect) {
                 $player->addEffect(Effect::getEffect((int) $effect["effect"])->setAmplifier((int) $effect["amplifier"])->setDuration((int) $effect["duration"] * 20)->setVisible((int) $effect["visible"]));
                 if ($effect["particle"] === "none") {
                     //
                 } elseif ($effect["particle"] === "bubble") {
                     $player->getLevel()->addParticle($bubble);
                 } elseif ($effect["particle"] === "critical") {
                     $player->getLevel()->addParticle($critical);
                 } elseif ($effect["particle"] === "enchant") {
                     $player->getLevel()->addParticle($enchant);
                 } elseif ($effect["particle"] === "flame") {
                     $player->getLevel()->addParticle($flame);
                 } elseif ($effect["particle"] === "heart") {
                     $player->getLevel()->addParticle($heart);
                 } elseif ($effect["particle"] === "ink") {
                     $player->getLevel()->addParticle($ink);
                 } elseif ($effect["particle"] === "lava") {
                     $player->getLevel()->addParticle($lava);
                 } elseif ($effect["particle"] === "portal") {
                     $player->getLevel()->addParticle($portal);
                 } elseif ($effect["particle"] === "smoke") {
                     $player->getLevel()->addParticle($smoke);
                 } elseif ($effect["particle"] === "water") {
                     $player->getLevel()->addParticle($water);
                 }
             }
         }
     }
 }

作者:CaptainKenji1    项目:StickPowe   
public function onHurt(EntityDamageEvent $event)
 {
     if ($event instanceof EntityDamageByEntityEvent) {
         $damager = $event->getDamager();
         $player = $event->getEntity();
         if ($damager instanceof Player) {
             if ($damager->getInventory()->getItemInHand()->getId() === 280) {
                 $event->setKnockBack($this->getConfig()->get("KnockBack-Power"));
                 $player->addEffect(Effect::getEffect(20)->setAmplifier(1)->setDuration(50)->setVisible(true));
                 $level = $damager->getLevel();
                 $level->addSound(new AnvilFallSound($damager->getLocation()));
             }
         }
     }
 }

作者:SirGame    项目:FreezeTa   
public function onRun($tick)
 {
     $this->plugin->gameduration -= 1;
     foreach ($this->plugin->getServer()->getOnlinePlayers() as $p) {
         if ($this->plugin->gameduration == 612) {
             $players = $this->plugin->getServer()->getOnlinePlayers();
             $effect = Effect::getEffect(1);
             $effect->setDuration(99999999);
             $effect->setAmplifier(0);
             $effect->setVisible(false);
             $ran1 = $this->plugin->getServer()->getPlayer($this->plugin->getConfig()->get("it1"));
             $ran2 = $this->plugin->getServer()->getPlayer($this->plugin->getConfig()->get("it2"));
             $ran3 = $this->plugin->getServer()->getPlayer($this->plugin->getConfig()->get("it3"));
             $ran1->addEffect($effect);
             $ran2->addEffect($effect);
             $ran3->addEffect($effect);
             $ran1->setNameTag(TextFormat::RED . "[RUN AWAY FROM ME]");
             $ran2->setNameTag(TextFormat::RED . "[RUN AWAY FROM ME]");
             $ran3->setNameTag(TextFormat::RED . "[RUN AWAY FROM ME]");
             $p->getInventory()->addItem(Item::get(280, 0, 1));
             $ran1->getInventory()->addItem(Item::get(276, 0, 1));
             $ran2->getInventory()->addItem(Item::get(276, 0, 1));
             $ran3->getInventory()->addItem(Item::get(276, 0, 1));
             $ran1->getInventory()->removeItem(Item::get(280, 0, 1));
             $ran2->getInventory()->removeItem(Item::get(280, 0, 1));
             $ran3->getInventory()->removeItem(Item::get(280, 0, 1));
             $ran3->sendMessage("Seems like your it! Tag Players with the sword.");
             $ran2->sendMessage("Seems like your it! Tag Players with the sword.");
             $ran1->sendMessage("Seems like your it! Tag Players with the sword.");
             $ran1->teleport(new Vector3(159, 4, 170));
             $ran2->teleport(new Vector3(159, 4, 170));
             $ran3->teleport(new Vector3(159, 4, 170));
             $this->plugin->getServer()->dispatchCommand(new ConsoleCommandSender(), "whitelist on");
         } elseif ($this->plugin->gameduration == 599) {
             $this->plugin->getServer()->getPlayer(strtolower($this->plugin->getConfig()->get("it1")))->teleport(new Vector3(153, 4, 128));
             $this->plugin->getServer()->getPlayer(strtolower($this->plugin->getConfig()->get("it2")))->teleport(new Vector3(153, 4, 128));
             $this->plugin->getServer()->getPlayer(strtolower($this->plugin->getConfig()->get("it3")))->teleport(new Vector3(153, 4, 128));
         }
     }
     if ($this->plugin->gameduration == 0) {
         $p->kick("Game Over");
     }
 }

作者:CreeperG    项目:Genisy   
public static function getColor($meta)
 {
     switch ($meta) {
         case self::INVISIBILITY:
         case self::INVISIBILITY_T:
             return Effect::getEffect(Effect::INVISIBILITY)->getColor();
         case self::LEAPING:
         case self::LEAPING_T:
         case self::LEAPING_TWO:
             return Effect::getEffect(Effect::JUMP)->getColor();
         case self::FIRE_RESISTANCE:
         case self::FIRE_RESISTANCE_T:
             return Effect::getEffect(Effect::FIRE_RESISTANCE)->getColor();
         case self::SPEED:
         case self::SPEED_T:
         case self::SPEED_TWO:
             return Effect::getEffect(Effect::SPEED)->getColor();
         case self::SLOWNESS:
         case self::SLOWNESS_T:
             return Effect::getEffect(Effect::SLOWNESS)->getColor();
         case self::WATER_BREATHING:
         case self::WATER_BREATHING_T:
             return Effect::getEffect(Effect::WATER_BREATHING)->getColor();
         case self::HARMING:
         case self::HARMING_TWO:
             return Effect::getEffect(Effect::HARMING)->getColor();
         case self::POISON:
         case self::POISON_T:
         case self::POISON_TWO:
             return Effect::getEffect(Effect::POISON)->getColor();
         case self::HEALING:
         case self::HEALING_TWO:
             return Effect::getEffect(Effect::HEALING)->getColor();
         case self::NIGHT_VISION:
         case self::NIGHT_VISION_T:
             return Effect::getEffect(Effect::NIGHT_VISION)->getColor();
         default:
             return Effect::getEffect(Effect::WATER_BREATHING)->getColor();
     }
 }

作者:PepbookPv    项目:Genisy   
public function eatFoodInHand()
 {
     if ($this->eatCoolDown + 2000 >= time() || !$this->spawned) {
         return;
     }
     $items = [Item::APPLE => 4, Item::MUSHROOM_STEW => 6, Item::BEETROOT_SOUP => 5, Item::BREAD => 5, Item::RAW_PORKCHOP => 2, Item::COOKED_PORKCHOP => 8, Item::RAW_BEEF => 3, Item::STEAK => 8, Item::COOKED_CHICKEN => 6, Item::RAW_CHICKEN => 2, Item::MELON_SLICE => 2, Item::GOLDEN_APPLE => 4, Item::PUMPKIN_PIE => 8, Item::CARROT => 3, Item::POTATO => 1, Item::BAKED_POTATO => 5, Item::COOKIE => 2, Item::COOKED_FISH => [0 => 5, 1 => 6], Item::RAW_FISH => [0 => 2, 1 => 2, 2 => 1, 3 => 1], Item::POTION => 0];
     $slot = $this->inventory->getItemInHand();
     if (isset($items[$slot->getId()]) and $this->isAlive()) {
         if ($this->getFood() < 20 and isset($items[$slot->getId()])) {
             $this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $slot));
             if ($ev->isCancelled()) {
                 $this->inventory->sendContents($this);
                 return;
             }
             $pk = new EntityEventPacket();
             $pk->eid = $this->getId();
             $pk->event = EntityEventPacket::USE_ITEM;
             $this->dataPacket($pk);
             Server::broadcastPacket($this->getViewers(), $pk);
             $amount = $items[$slot->getId()];
             if (is_array($amount)) {
                 $amount = isset($amount[$slot->getDamage()]) ? $amount[$slot->getDamage()] : 0;
             }
             if ($this->getFood() + $amount >= 20) {
                 $this->setFood(20);
             } else {
                 $this->setFood($this->getFood() + $amount);
             }
             --$slot->count;
             $this->inventory->setItemInHand($slot);
             if ($slot->getId() === Item::MUSHROOM_STEW or $slot->getId() === Item::BEETROOT_SOUP) {
                 $this->inventory->addItem(Item::get(Item::BOWL, 0, 1));
             } elseif ($slot->getId() === Item::RAW_FISH and $slot->getDamage() === 3) {
                 //Pufferfish
                 $this->addEffect(Effect::getEffect(Effect::HUNGER)->setAmplifier(2)->setDuration(15 * 20));
                 $this->addEffect(Effect::getEffect(Effect::NAUSEA)->setAmplifier(1)->setDuration(15 * 20));
                 $this->addEffect(Effect::getEffect(Effect::POISON)->setAmplifier(3)->setDuration(60 * 20));
             } elseif ($slot->getId() === Item::GOLDEN_APPLE && $slot->getDamage() === 1) {
                 $this->setFood($this->getFood() + 4);
                 //$this->addEffect(Effect::getEffect(Effect::HEALTH_BOOST)->setAmplifier(0)->setDuration(2 * 60 * 20));
                 $this->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(4)->setDuration(30 * 20));
                 $this->addEffect(Effect::getEffect(Effect::FIRE_RESISTANCE)->setAmplifier(0)->setDuration(5 * 60 * 20));
                 $this->addEffect(Effect::getEffect(Effect::DAMAGE_RESISTANCE)->setAmplifier(0)->setDuration(5 * 60 * 20));
                 //$this->addEffect(Effect::getEffect(Effect::ABSORPTION)->setDuration(2 * 60 * 20));
             } elseif ($slot->getId() === Item::GOLDEN_APPLE) {
                 $this->setFood($this->getFood() + 4);
                 //$this->addEffect(Effect::getEffect(Effect::HEALTH_BOOST)->setAmplifier(0)->setDuration(2 * 60 * 20));
                 $this->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(1)->setDuration(5 * 20));
             } elseif ($slot->getId() == Item::POTION) {
                 $this->inventory->addItem(new Item(Item::POTION));
                 switch ($slot->getDamage()) {
                     case Potion::NIGHT_VISION:
                         $this->addEffect(Effect::getEffect(Effect::NIGHT_VISION)->setAmplifier(0)->setDuration(3 * 60 * 20));
                         break;
                     case Potion::NIGHT_VISION_T:
                         $this->addEffect(Effect::getEffect(Effect::NIGHT_VISION)->setAmplifier(0)->setDuration(8 * 60 * 20));
                         break;
                     case Potion::INVISIBILITY:
                         $this->addEffect(Effect::getEffect(Effect::INVISIBILITY)->setAmplifier(0)->setDuration(3 * 60 * 20));
                         break;
                     case Potion::INVISIBILITY_T:
                         $this->addEffect(Effect::getEffect(Effect::INVISIBILITY)->setAmplifier(0)->setDuration(8 * 60 * 20));
                         break;
                     case Potion::LEAPING:
                         $this->addEffect(Effect::getEffect(Effect::JUMP)->setAmplifier(0)->setDuration(3 * 60 * 20));
                         break;
                     case Potion::LEAPING_T:
                         $this->addEffect(Effect::getEffect(Effect::JUMP)->setAmplifier(0)->setDuration(8 * 60 * 20));
                         break;
                     case Potion::LEAPING_TWO:
                         $this->addEffect(Effect::getEffect(Effect::JUMP)->setAmplifier(1)->setDuration(1.5 * 60 * 20));
                         break;
                     case Potion::FIRE_RESISTANCE:
                         $this->addEffect(Effect::getEffect(Effect::FIRE_RESISTANCE)->setAmplifier(0)->setDuration(3 * 60 * 20));
                         break;
                     case Potion::FIRE_RESISTANCE_T:
                         $this->addEffect(Effect::getEffect(Effect::FIRE_RESISTANCE)->setAmplifier(0)->setDuration(8 * 60 * 20));
                         break;
                     case Potion::SPEED:
                         $this->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(0)->setDuration(3 * 60 * 20));
                         break;
                     case Potion::SPEED_T:
                         $this->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(0)->setDuration(8 * 60 * 20));
                         break;
                     case Potion::SPEED_TWO:
                         $this->addEffect(Effect::getEffect(Effect::SPEED)->setAmplifier(1)->setDuration(1.5 * 60 * 20));
                         break;
                     case Potion::SLOWNESS:
                         $this->addEffect(Effect::getEffect(Effect::SLOWNESS)->setAmplifier(0)->setDuration(1 * 60 * 20));
                         break;
                     case Potion::SLOWNESS_T:
                         $this->addEffect(Effect::getEffect(Effect::SLOWNESS)->setAmplifier(0)->setDuration(4 * 60 * 20));
                         break;
                     case Potion::WATER_BREATHING:
                         $this->addEffect(Effect::getEffect(Effect::WATER_BREATHING)->setAmplifier(0)->setDuration(3 * 60 * 20));
                         break;
                     case Potion::WATER_BREATHING_T:
                         $this->addEffect(Effect::getEffect(Effect::WATER_BREATHING)->setAmplifier(0)->setDuration(8 * 60 * 20));
                         break;
                     case Potion::POISON:
//.........这里部分代码省略.........

作者:ZenaGamingsk    项目:PocketBo   
//.........这里部分代码省略.........
     @touch($this->dataPath . "banned-ips.txt");
     $this->banByIP = new BanList($this->dataPath . "banned-ips.txt");
     $this->banByIP->load();
     $this->maxPlayers = $this->getConfigInt("max-players", 20);
     $this->setAutoSave($this->getConfigBoolean("auto-save", true));
     if ($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3) {
         $this->setConfigInt("difficulty", 3);
     }
     define("pocketmine\\DEBUG", (int) $this->getProperty("debug.level", 1));
     if ($this->logger instanceof MainLogger) {
         $this->logger->setLogDebug(\pocketmine\DEBUG > 1);
     }
     if (\pocketmine\DEBUG >= 0) {
         @cli_set_process_title($this->getName() . " " . $this->getPocketMineVersion());
     }
     $this->logger->info($this->getLanguage()->translateString("pocketmine.server.networkStart", [$this->getIp() === "" ? "*" : $this->getIp(), $this->getPort()]));
     define("BOOTUP_RANDOM", @Utils::getRandomBytes(16));
     $this->serverID = Utils::getMachineUniqueId($this->getIp() . $this->getPort());
     $this->getLogger()->debug("Server unique id: " . $this->getServerUniqueId());
     $this->getLogger()->debug("Machine unique id: " . Utils::getMachineUniqueId());
     $this->network = new Network($this);
     $this->network->setName($this->getMotd());
     $this->logger->info($this->getLanguage()->translateString("pocketmine.server.info", [$this->getName(), ($version->isDev() ? TextFormat::YELLOW : "") . $version->get(true) . TextFormat::WHITE, $this->getCodename(), $this->getApiVersion()]));
     $this->logger->info($this->getLanguage()->translateString("pocketmine.server.license", [$this->getName()]));
     Timings::init();
     $this->consoleSender = new ConsoleCommandSender();
     $this->commandMap = new SimpleCommandMap($this);
     $this->registerEntities();
     $this->registerTiles();
     InventoryType::init();
     Block::init();
     Item::init();
     Biome::init();
     Effect::init();
     Enchantment::init();
     Attribute::init();
     /** TODO: @deprecated */
     TextWrapper::init();
     $this->craftingManager = new CraftingManager();
     $this->pluginManager = new PluginManager($this, $this->commandMap);
     $this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender);
     $this->pluginManager->setUseTimings($this->getProperty("settings.enable-profiling", false));
     $this->profilingTickRate = (double) $this->getProperty("settings.profile-report-trigger", 20);
     $this->pluginManager->registerInterface(PharPluginLoader::class);
     $this->pluginManager->registerInterface(ScriptPluginLoader::class);
     set_exception_handler([$this, "exceptionHandler"]);
     register_shutdown_function([$this, "crashDump"]);
     $this->queryRegenerateTask = new QueryRegenerateEvent($this, 5);
     $this->network->registerInterface(new RakLibInterface($this));
     $this->pluginManager->loadPlugins($this->pluginPath);
     $this->updater = new AutoUpdater($this, $this->getProperty("auto-updater.host", "www.pocketmine.net"));
     $this->enablePlugins(PluginLoadOrder::STARTUP);
     LevelProviderManager::addProvider($this, Anvil::class);
     LevelProviderManager::addProvider($this, McRegion::class);
     if (extension_loaded("leveldb")) {
         $this->logger->debug($this->getLanguage()->translateString("pocketmine.debug.enable"));
         LevelProviderManager::addProvider($this, LevelDB::class);
     }
     Generator::addGenerator(Flat::class, "flat");
     Generator::addGenerator(Normal::class, "normal");
     Generator::addGenerator(Normal::class, "default");
     Generator::addGenerator(Nether::class, "hell");
     Generator::addGenerator(Nether::class, "nether");
     foreach ((array) $this->getProperty("worlds", []) as $name => $worldSetting) {
         if ($this->loadLevel($name) === false) {
             $seed = $this->getProperty("worlds.{$name}.seed", time());

作者:iTXTec    项目:Genisy   
public function getAdditionalEffects() : array
 {
     return [Effect::getEffect(Effect::POISON)->setDuration(80)];
 }

作者:maa12    项目:NIGHTMAR   
public function getEffects()
 {
     return $this->meta === self::PUFFERFISH ? [[Effect::getEffect(Effect::NAUSEA)->setDuration(15 * 20)->setAmplifier(1), 1], [Effect::getEffect(Effect::HUNGER)->setDuration(15 * 20)->setAmplifier(2), 1], [Effect::getEffect(Effect::POISON)->setDuration(60 * 20)->setAmplifier(3), 1]] : [];
 }


问题


面经


文章

微信
公众号

扫码关注公众号