コード例 #1
1
ファイル: EventListener.php プロジェクト: jjplaying/HotBlock
 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;
         }
     }
 }
コード例 #2
0
ファイル: Plugin.php プロジェクト: Pab450/SkyWorld_Server
 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));
     }
 }
コード例 #3
0
ファイル: Speed.php プロジェクト: PrimusLV/EssentialsPE
 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;
 }
コード例 #4
0
ファイル: Main.php プロジェクト: betausing/Private-Plugins
 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);
             }
         }
     }
 }
コード例 #5
0
ファイル: SignMgr.php プロジェクト: DWWf/pocketmine-plugins
 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;
 }
コード例 #6
0
ファイル: Main.php プロジェクト: xHFx/SwordEffects
 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));
         }
     }
 }
コード例 #7
0
 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));
     }
 }
コード例 #8
0
 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;
 }
コード例 #9
0
ファイル: RottenFlesh.php プロジェクト: iTXTech/Genisys
 public function getAdditionalEffects() : array
 {
     $chance = mt_rand(0, 100);
     if ($chance >= 20) {
         return [Effect::getEffect(Effect::HUNGER)->setDuration(30 * 20)];
     } else {
         return [];
     }
 }
コード例 #10
0
 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));
     }
 }
コード例 #11
0
ファイル: Main.php プロジェクト: EpicArtz08999/Ezeron
 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);
     }
 }
コード例 #12
0
ファイル: Main.php プロジェクト: BrokenLens/PhpStormPlugin
 /**
  * @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);
     }
 }
コード例 #13
0
 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);
                 }
             }
         }
     }
 }
コード例 #14
0
ファイル: Main.php プロジェクト: CaptainKenji17/StickPower
 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()));
             }
         }
     }
 }
コード例 #15
0
ファイル: GameTask.php プロジェクト: SirGamer/FreezeTag
 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");
     }
 }
コード例 #16
0
ファイル: Potion.php プロジェクト: CreeperGo/Genisys
 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();
     }
 }
コード例 #17
0
ファイル: Player.php プロジェクト: PepbookPvP/Genisys
 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:
                         $this->addEffect(Effect::getEffect(Effect::POISON)->setAmplifier(0)->setDuration(45 * 20));
                         break;
                     case Potion::POISON_T:
                         $this->addEffect(Effect::getEffect(Effect::POISON)->setAmplifier(0)->setDuration(2 * 60 * 20));
                         break;
                     case Potion::POISON_TWO:
                         $this->addEffect(Effect::getEffect(Effect::POISON)->setAmplifier(0)->setDuration(22 * 20));
                         break;
                     case Potion::REGENERATION:
                         $this->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(0)->setDuration(45 * 20));
                         break;
                     case Potion::REGENERATION_T:
                         $this->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(0)->setDuration(2 * 60 * 20));
                         break;
                     case Potion::REGENERATION_TWO:
                         $this->addEffect(Effect::getEffect(Effect::REGENERATION)->setAmplifier(1)->setDuration(22 * 20));
                         break;
                     case Potion::STRENGTH:
                         $this->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(0)->setDuration(3 * 60 * 20));
                         break;
                     case Potion::STRENGTH_T:
                         $this->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(0)->setDuration(8 * 60 * 20));
                         break;
                     case Potion::STRENGTH_TWO:
                         $this->addEffect(Effect::getEffect(Effect::STRENGTH)->setAmplifier(1)->setDuration(1.5 * 60 * 20));
                         break;
                     case Potion::WEAKNESS:
                         $this->addEffect(Effect::getEffect(Effect::WEAKNESS)->setAmplifier(0)->setDuration(1.5 * 60 * 20));
                         break;
                     case Potion::WEAKNESS_T:
                         $this->addEffect(Effect::getEffect(Effect::WEAKNESS)->setAmplifier(0)->setDuration(4 * 60 * 20));
                         break;
                     case Potion::HEALING:
                         $this->addEffect(Effect::getEffect(Effect::HEALING)->setAmplifier(0)->setDuration(1));
                         break;
                     case Potion::HEALING_TWO:
                         $this->addEffect(Effect::getEffect(Effect::HEALING)->setAmplifier(1)->setDuration(1));
                         break;
                     case Potion::HARMING:
                         $this->addEffect(Effect::getEffect(Effect::HARMING)->setAmplifier(0)->setDuration(1));
                         break;
                     case Potion::HARMING_TWO:
                         $this->addEffect(Effect::getEffect(Effect::HARMING)->setAmplifier(1)->setDuration(1));
                         break;
                 }
             }
         }
     }
 }
コード例 #18
0
ファイル: Server.php プロジェクト: ZenaGamingsky/PocketBox
 /**
  * @param \ClassLoader    $autoloader
  * @param \ThreadedLogger $logger
  * @param string          $filePath
  * @param string          $dataPath
  * @param string          $pluginPath
  */
 public function __construct(\ClassLoader $autoloader, \ThreadedLogger $logger, $filePath, $dataPath, $pluginPath)
 {
     self::$instance = $this;
     $this->autoloader = $autoloader;
     $this->logger = $logger;
     $this->filePath = $filePath;
     if (!file_exists($dataPath . "worlds/")) {
         mkdir($dataPath . "worlds/", 0777);
     }
     if (!file_exists($dataPath . "players/")) {
         mkdir($dataPath . "players/", 0777);
     }
     if (!file_exists($dataPath . "CrashDump/")) {
         mkdir($dataPath . "CrashDump/", 0777);
     }
     if (!file_exists($pluginPath)) {
         mkdir($pluginPath, 0777);
     }
     $this->dataPath = realpath($dataPath) . DIRECTORY_SEPARATOR;
     $this->pluginPath = realpath($pluginPath) . DIRECTORY_SEPARATOR;
     $this->console = new CommandReader();
     $version = new VersionString($this->getPocketMineVersion());
     $this->logger->info(TextFormat::GREEN . "  ____            _        _   __  __ _                     " . TextFormat::AQUA . " _____ _ _ _       ");
     $this->logger->info(TextFormat::GREEN . " |  _ \\ ___   ___| | _____| |_|  \\/  (_)_ __   ___          " . TextFormat::AQUA . "| ____| (_) |_ ___ ");
     $this->logger->info(TextFormat::GREEN . " | |_) / _ \\ / __| |/ / _ \\ __| |\\/| | | '_ \\ / _ \\  _____  " . TextFormat::AQUA . "|  _| | | | __/ _ \\ ");
     $this->logger->info(TextFormat::GREEN . " |  __/ (_) | (__|   <  __/ |_| |  | | | | | |  __/ |_____| " . TextFormat::AQUA . "| |___| | | ||  __/");
     $this->logger->info(TextFormat::GREEN . " |_|   \\___/ \\___|_|\\_\\___|\\__|_|  |_|_|_| |_|\\___|         " . TextFormat::AQUA . "|_____|_|_|\\__\\___|");
     $this->logger->info(TextFormat::GREEN . "                               Version: " . TextFormat::AQUA . $version);
     $this->logger->info("Loading pocketmine.yml...");
     if (!file_exists($this->dataPath . "pocketmine.yml")) {
         $content = file_get_contents($this->filePath . "src/pocketmine/resources/pocketmine.yml");
         if ($version->isDev()) {
             $content = str_replace("preferred-channel: stable", "preferred-channel: beta", $content);
         }
         @file_put_contents($this->dataPath . "pocketmine.yml", $content);
     }
     $this->config = new Config($this->dataPath . "pocketmine.yml", Config::YAML, []);
     $this->logger->info("Loading server properties...");
     $this->properties = new Config($this->dataPath . "server.properties", Config::PROPERTIES, ["motd" => "Minecraft: PE Server", "server-port" => 19132, "white-list" => false, "announce-player-achievements" => true, "spawn-protection" => 16, "max-players" => 20, "allow-flight" => false, "spawn-animals" => true, "spawn-mobs" => true, "gamemode" => 0, "force-gamemode" => false, "hardcore" => false, "pvp" => true, "difficulty" => 1, "generator-settings" => "", "level-name" => "world", "level-seed" => "", "level-type" => "DEFAULT", "enable-query" => true, "enable-rcon" => false, "rcon.password" => substr(base64_encode(@Utils::getRandomBytes(20, false)), 3, 10), "auto-save" => true]);
     $this->forceLanguage = $this->getProperty("settings.force-language", false);
     $this->baseLang = new BaseLang($this->getProperty("settings.language", BaseLang::FALLBACK_LANGUAGE));
     $this->logger->info($this->getLanguage()->translateString("language.selected", [$this->getLanguage()->getName(), $this->getLanguage()->getLang()]));
     $this->memoryManager = new MemoryManager($this);
     $this->logger->info($this->getLanguage()->translateString("pocketmine.server.start", [TextFormat::AQUA . $this->getVersion()]));
     if (($poolSize = $this->getProperty("settings.async-workers", "auto")) === "auto") {
         $poolSize = ServerScheduler::$WORKERS;
         $processors = Utils::getCoreCount() - 2;
         if ($processors > 0) {
             $poolSize = max(1, $processors);
         }
     }
     ServerScheduler::$WORKERS = $poolSize;
     if ($this->getProperty("network.batch-threshold", 256) >= 0) {
         Network::$BATCH_THRESHOLD = (int) $this->getProperty("network.batch-threshold", 256);
     } else {
         Network::$BATCH_THRESHOLD = -1;
     }
     $this->networkCompressionLevel = $this->getProperty("network.compression-level", 7);
     $this->networkCompressionAsync = $this->getProperty("network.async-compression", true);
     $this->autoTickRate = (bool) $this->getProperty("level-settings.auto-tick-rate", true);
     $this->autoTickRateLimit = (int) $this->getProperty("level-settings.auto-tick-rate-limit", 20);
     $this->alwaysTickPlayers = (int) $this->getProperty("level-settings.always-tick-players", false);
     $this->baseTickRate = (int) $this->getProperty("level-settings.base-tick-rate", 1);
     $this->scheduler = new ServerScheduler();
     if ($this->getConfigBoolean("enable-rcon", false) === true) {
         $this->rcon = new RCON($this, $this->getConfigString("rcon.password", ""), $this->getConfigInt("rcon.port", $this->getPort()), ($ip = $this->getIp()) != "" ? $ip : "0.0.0.0", $this->getConfigInt("rcon.threads", 1), $this->getConfigInt("rcon.clients-per-thread", 50));
     }
     $this->entityMetadata = new EntityMetadataStore();
     $this->playerMetadata = new PlayerMetadataStore();
     $this->levelMetadata = new LevelMetadataStore();
     $this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM);
     $this->whitelist = new Config($this->dataPath . "white-list.txt", Config::ENUM);
     if (file_exists($this->dataPath . "banned.txt") and !file_exists($this->dataPath . "banned-players.txt")) {
         @rename($this->dataPath . "banned.txt", $this->dataPath . "banned-players.txt");
     }
     @touch($this->dataPath . "banned-players.txt");
     $this->banByName = new BanList($this->dataPath . "banned-players.txt");
     $this->banByName->load();
     @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());
             $options = explode(":", $this->getProperty("worlds.{$name}.generator", Generator::getGenerator("default")));
             $generator = Generator::getGenerator(array_shift($options));
             if (count($options) > 0) {
                 $options = ["preset" => implode(":", $options)];
             } else {
                 $options = [];
             }
             $this->generateLevel($name, $seed, $generator, $options);
         }
     }
     if ($this->getDefaultLevel() === null) {
         $default = $this->getConfigString("level-name", "world");
         if (trim($default) == "") {
             $this->getLogger()->warning("level-name cannot be null, using default");
             $default = "world";
             $this->setConfigString("level-name", "world");
         }
         if ($this->loadLevel($default) === false) {
             $seed = $this->getConfigInt("level-seed", time());
             $this->generateLevel($default, $seed === 0 ? time() : $seed);
         }
         $this->setDefaultLevel($this->getLevelByName($default));
     }
     $this->properties->save(true);
     if (!$this->getDefaultLevel() instanceof Level) {
         $this->getLogger()->emergency($this->getLanguage()->translateString("pocketmine.level.defaultError"));
         $this->forceShutdown();
         return;
     }
     if ($this->getProperty("ticks-per.autosave", 6000) > 0) {
         $this->autoSaveTicks = (int) $this->getProperty("ticks-per.autosave", 6000);
     }
     $this->enablePlugins(PluginLoadOrder::POSTWORLD);
     $this->start();
 }
コード例 #19
0
ファイル: SpiderEye.php プロジェクト: iTXTech/Genisys
 public function getAdditionalEffects() : array
 {
     return [Effect::getEffect(Effect::POISON)->setDuration(80)];
 }
コード例 #20
0
ファイル: Fish.php プロジェクト: maa123/NIGHTMARE
 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]] : [];
 }
コード例 #21
0
ファイル: Server.php プロジェクト: ZenaGamingsky/Steadfast2
 /**
  * Starts the PocketMine-MP server and starts processing ticks and packets
  */
 public function start()
 {
     if ($this->getConfigBoolean("enable-query", true) === true) {
         $this->queryHandler = new QueryHandler();
     }
     foreach ($this->getIPBans()->getEntries() as $entry) {
         $this->network->blockAddress($entry->getName(), -1);
     }
     if ($this->getProperty("settings.send-usage", true) !== false) {
         $this->scheduler->scheduleDelayedRepeatingTask(new CallbackTask([$this, "sendUsage"]), 6000, 6000);
         $this->sendUsage();
     }
     if ($this->getProperty("settings.upnp-forwarding", false) == true) {
         $this->logger->info("[UPnP] Trying to port forward...");
         UPnP::PortForward($this->getPort());
     }
     $this->tickCounter = 0;
     if (function_exists("pcntl_signal")) {
         pcntl_signal(SIGTERM, [$this, "handleSignal"]);
         pcntl_signal(SIGINT, [$this, "handleSignal"]);
         pcntl_signal(SIGHUP, [$this, "handleSignal"]);
         $this->getScheduler()->scheduleRepeatingTask(new CallbackTask("pcntl_signal_dispatch"), 5);
     }
     $this->getScheduler()->scheduleRepeatingTask(new CallbackTask([$this, "checkTicks"]), 20 * 5);
     $this->logger->info("Default game type: " . self::getGamemodeString($this->getGamemode()));
     Effect::init();
     $this->logger->info("Done (" . round(microtime(true) - \pocketmine\START_TIME, 3) . 's)! For help, type "help" or "?"');
     $this->tickProcessor();
     $this->forceShutdown();
     \gc_collect_cycles();
 }
コード例 #22
0
ファイル: Potion.php プロジェクト: ecoron/MinionsLandPE
 public function getEffects()
 {
     $effect = [];
     switch ($this->meta) {
         case Potion::NIGHT_VISION:
             $effect = [[Effect::getEffect(Effect::NIGHT_VISION)->setAmplifier(0)->setDuration(3 * 60 * 20), 1]];
             break;
         case Potion::NIGHT_VISION_T:
             $effect = [[Effect::getEffect(Effect::NIGHT_VISION)->setAmplifier(0)->setDuration(8 * 60 * 20), 1]];
             break;
         case Potion::INVISIBILITY:
             $effect = [[Effect::getEffect(Effect::INVISIBILITY)->setAmplifier(0)->setDuration(3 * 60 * 20), 1]];
             break;
         case Potion::INVISIBILITY_T:
             $effect = [[Effect::getEffect(Effect::INVISIBILITY)->setAmplifier(0)->setDuration(8 * 60 * 20), 1]];
             break;
         case Potion::LEAPING:
             $effect = [[Effect::getEffect(Effect::JUMP)->setAmplifier(0)->setDuration(3 * 60 * 20), 1]];
             break;
         case Potion::LEAPING_T:
             $effect = [[Effect::getEffect(Effect::JUMP)->setAmplifier(0)->setDuration(8 * 60 * 20), 1]];
             break;
         case Potion::LEAPING_TWO:
             $effect = [[Effect::getEffect(Effect::JUMP)->setAmplifier(1)->setDuration(1.5 * 60 * 20), 1]];
             break;
         case Potion::FIRE_RESISTANCE:
             $effect = [[Effect::getEffect(Effect::FIRE_RESISTANCE)->setAmplifier(0)->setDuration(3 * 60 * 20), 1]];
             break;
         case Potion::FIRE_RESISTANCE_T:
             $effect = [[Effect::getEffect(Effect::FIRE_RESISTANCE)->setAmplifier(0)->setDuration(8 * 60 * 20), 1]];
             break;
         case Potion::SPEED:
             $effect = [[Effect::getEffect(Effect::SPEED)->setAmplifier(0)->setDuration(3 * 60 * 20), 1]];
             break;
         case Potion::SPEED_T:
             $effect = [[Effect::getEffect(Effect::SPEED)->setAmplifier(0)->setDuration(8 * 60 * 20), 1]];
             break;
         case Potion::SPEED_TWO:
             $effect = [[Effect::getEffect(Effect::SPEED)->setAmplifier(1)->setDuration(1.5 * 60 * 20), 1]];
             break;
         case Potion::SLOWNESS:
             $effect = [[Effect::getEffect(Effect::SLOWNESS)->setAmplifier(0)->setDuration(1 * 60 * 20), 1]];
             break;
         case Potion::SLOWNESS_T:
             $effect = [[Effect::getEffect(Effect::SLOWNESS)->setAmplifier(0)->setDuration(4 * 60 * 20), 1]];
             break;
         case Potion::WATER_BREATHING:
             $effect = [[Effect::getEffect(Effect::WATER_BREATHING)->setAmplifier(0)->setDuration(3 * 60 * 20), 1]];
             break;
         case Potion::WATER_BREATHING_T:
             $effect = [[Effect::getEffect(Effect::WATER_BREATHING)->setAmplifier(0)->setDuration(8 * 60 * 20), 1]];
             break;
         case Potion::POISON:
             $effect = [[Effect::getEffect(Effect::POISON)->setAmplifier(0)->setDuration(45 * 20), 1]];
             break;
         case Potion::POISON_T:
             $effect = [[Effect::getEffect(Effect::POISON)->setAmplifier(0)->setDuration(2 * 60 * 20), 1]];
             break;
         case Potion::POISON_TWO:
             $effect = [[Effect::getEffect(Effect::POISON)->setAmplifier(0)->setDuration(22 * 20), 1]];
             break;
         case Potion::REGENERATION:
             $effect = [[Effect::getEffect(Effect::REGENERATION)->setAmplifier(0)->setDuration(45 * 20), 1]];
             break;
         case Potion::REGENERATION_T:
             $effect = [[Effect::getEffect(Effect::REGENERATION)->setAmplifier(0)->setDuration(2 * 60 * 20), 1]];
             break;
         case Potion::REGENERATION_TWO:
             $effect = [[Effect::getEffect(Effect::REGENERATION)->setAmplifier(1)->setDuration(22 * 20), 1]];
             break;
         case Potion::STRENGTH:
             $effect = [[Effect::getEffect(Effect::STRENGTH)->setAmplifier(0)->setDuration(3 * 60 * 20), 1]];
             break;
         case Potion::STRENGTH_T:
             $effect = [[Effect::getEffect(Effect::STRENGTH)->setAmplifier(0)->setDuration(8 * 60 * 20), 1]];
             break;
         case Potion::STRENGTH_TWO:
             $effect = [[Effect::getEffect(Effect::STRENGTH)->setAmplifier(1)->setDuration(1.5 * 60 * 20), 1]];
             break;
         case Potion::WEAKNESS:
             $effect = [[Effect::getEffect(Effect::WEAKNESS)->setAmplifier(0)->setDuration(1.5 * 60 * 20), 1]];
             break;
         case Potion::WEAKNESS_T:
             $effect = [[Effect::getEffect(Effect::WEAKNESS)->setAmplifier(0)->setDuration(4 * 60 * 20), 1]];
             break;
         case Potion::HEALING:
             $effect = [[Effect::getEffect(Effect::HEALING)->setAmplifier(0)->setDuration(1), 1]];
             break;
         case Potion::HEALING_TWO:
             $effect = [[Effect::getEffect(Effect::HEALING)->setAmplifier(1)->setDuration(1), 1]];
             break;
         case Potion::HARMING:
             $effect = [[Effect::getEffect(Effect::HARMING)->setAmplifier(0)->setDuration(1), 1]];
             break;
         case Potion::HARMING_TWO:
             $effect = [[Effect::getEffect(Effect::HARMING)->setAmplifier(1)->setDuration(1), 1]];
             break;
         default:
             $effect = [];
             break;
     }
     return $effect;
 }
コード例 #23
0
ファイル: EffectCommand.php プロジェクト: TexusDark/Ananas-MP
 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;
 }
コード例 #24
0
ファイル: Entity.php プロジェクト: Cybertechpp/Steadfast2
 protected function initEntity()
 {
     if (isset($this->namedtag->ActiveEffects)) {
         foreach ($this->namedtag->ActiveEffects->getValue() as $e) {
             $effect = Effect::getEffect($e["Id"]);
             if ($effect === \null) {
                 continue;
             }
             $effect->setAmplifier($e["Amplifier"])->setDuration($e["Duration"])->setVisible($e["ShowParticles"] > 0);
             $this->addEffect($effect);
         }
     }
 }
コード例 #25
0
ファイル: effect.php プロジェクト: sJimin/PHPTEST
 public function onTouch(PlayerInteractEvent $event)
 {
     $player = $event->getPlayer();
     if ($event->getBlock()->getId() == Block::SIGN_POST or $event->getBlock()->getId() == Block::WALL_SIGN) {
         $tile = $event->getBlock()->getLevel()->getTile($event->getBlock());
         if ($tile instanceof Sign) {
             $text = $tile->getText();
             /*
             if($text[0]=="-----------"&&$text[0]==TextFormat::RED."[E".TextFormat::GOLD."f".TextFormat::YELLOW."f".TextFormat::GREEN."e".TextFormat::BLUE."c".TextFormat::DARK_PURPLE."t]"&&$text[2]==TextFormat::AQUA."신속"&&$text[3]=="-----------"){
             $effect= Effect::getEffect(1);
             $effect->setDuration (300 * 20);
             $effect->setAmplifier (3);
             $player->addEffect($effect);
             }
             */
             //TODO 신속
             /*
             if($text[0]=="-----------"&&$text[0]==TextFormat::RED."[E".TextFormat::GOLD."f".TextFormat::YELLOW."f".TextFormat::GREEN."e".TextFormat::BLUE."c".TextFormat::DARK_PURPLE."t]"&&$text[2]==TextFormat::AQUA."구속"&&$text[3]=="-----------"){
             $effect= Effect::getEffect(2);
             $effect->setDuration (300 * 20);
             $effect->setAmplifier (3);
             $player->addEffect($effect);
             }
             */
             //TODO 구속
             if ($text[0] == "-----------" && $text[1] == TextFormat::RED . "[E" . TextFormat::GOLD . "f" . TextFormat::YELLOW . "f" . TextFormat::GREEN . "e" . TextFormat::BLUE . "c" . TextFormat::DARK_PURPLE . "t]" && $text[2] == TextFormat::AQUA . "성급함" && $text[3] == "-----------") {
                 $effect = Effect::getEffect(3);
                 $effect->setDuration(300 * 20);
                 $effect->setAmplifier(3);
                 $player->addEffect($effect);
             }
             if ($text[0] == "-----------" && $text[1] == TextFormat::RED . "[E" . TextFormat::GOLD . "f" . TextFormat::YELLOW . "f" . TextFormat::GREEN . "e" . TextFormat::BLUE . "c" . TextFormat::DARK_PURPLE . "t]" && $text[2] == TextFormat::AQUA . "피로" && $text[3] == "-----------") {
                 $effect = Effect::getEffect(4);
                 $effect->setDuration(300 * 20);
                 $effect->setAmplifier(3);
                 $player->addEffect($effect);
             }
             if ($text[0] == "-----------" && $text[1] == TextFormat::RED . "[E" . TextFormat::GOLD . "f" . TextFormat::YELLOW . "f" . TextFormat::GREEN . "e" . TextFormat::BLUE . "c" . TextFormat::DARK_PURPLE . "t]" && $text[2] == TextFormat::AQUA . "힘강화" && $text[3] == "-----------") {
                 $effect = Effect::getEffect(5);
                 $effect->setDuration(300 * 20);
                 $effect->setAmplifier(3);
                 $player->addEffect($effect);
             }
             if ($text[0] == "-----------" && $text[1] == TextFormat::RED . "[E" . TextFormat::GOLD . "f" . TextFormat::YELLOW . "f" . TextFormat::GREEN . "e" . TextFormat::BLUE . "c" . TextFormat::DARK_PURPLE . "t]" && $text[2] == TextFormat::AQUA . "점프강화" && $text[3] == "-----------") {
                 $effect = Effect::getEffect(8);
                 $effect->setDuration(300 * 20);
                 $effect->setAmplifier(4);
                 $player->addEffect($effect);
             }
             if ($text[0] == "-----------" && $text[1] == TextFormat::RED . "[E" . TextFormat::GOLD . "f" . TextFormat::YELLOW . "f" . TextFormat::GREEN . "e" . TextFormat::BLUE . "c" . TextFormat::DARK_PURPLE . "t]" && $text[2] == TextFormat::AQUA . "멀미" && $text[3] == "-----------") {
                 $effect = Effect::getEffect(9);
                 $effect->setDuration(300 * 20);
                 $effect->setAmplifier(1);
                 $player->addEffect($effect);
             }
             if ($text[0] == "-----------" && $text[1] == TextFormat::RED . "[E" . TextFormat::GOLD . "f" . TextFormat::YELLOW . "f" . TextFormat::GREEN . "e" . TextFormat::BLUE . "c" . TextFormat::DARK_PURPLE . "t]" && $text[2] == TextFormat::AQUA . "재생" && $text[3] == "-----------") {
                 $effect = Effect::getEffect(10);
                 $effect->setDuration(300 * 20);
                 $effect->setAmplifier(3);
                 $player->addEffect($effect);
             }
             if ($text[0] == "-----------" && $text[1] == TextFormat::RED . "[E" . TextFormat::GOLD . "f" . TextFormat::YELLOW . "f" . TextFormat::GREEN . "e" . TextFormat::BLUE . "c" . TextFormat::DARK_PURPLE . "t]" && $text[2] == TextFormat::AQUA . "저항" && $text[3] == "-----------") {
                 $effect = Effect::getEffect(11);
                 $effect->setDuration(300 * 20);
                 $effect->setAmplifier(3);
                 $player->addEffect($effect);
             }
             if ($text[0] == "-----------" && $text[1] == TextFormat::RED . "[E" . TextFormat::GOLD . "f" . TextFormat::YELLOW . "f" . TextFormat::GREEN . "e" . TextFormat::BLUE . "c" . TextFormat::DARK_PURPLE . "t]" && $text[2] == TextFormat::AQUA . "화염저항" && $text[3] == "-----------") {
                 $effect = Effect::getEffect(12);
                 $effect->setDuration(300 * 20);
                 $effect->setAmplifier(3);
                 $player->addEffect($effect);
             }
             if ($text[0] == "-----------" && $text[1] == TextFormat::RED . "[E" . TextFormat::GOLD . "f" . TextFormat::YELLOW . "f" . TextFormat::GREEN . "e" . TextFormat::BLUE . "c" . TextFormat::DARK_PURPLE . "t]" && $text[2] == TextFormat::AQUA . "수중호흡" && $text[3] == "-----------") {
                 $effect = Effect::getEffect(13);
                 $effect->setDuration(300 * 20);
                 $effect->setAmplifier(3);
                 $player->addEffect($effect);
             }
             if ($text[0] == "-----------" && $text[1] == TextFormat::RED . "[E" . TextFormat::GOLD . "f" . TextFormat::YELLOW . "f" . TextFormat::GREEN . "e" . TextFormat::BLUE . "c" . TextFormat::DARK_PURPLE . "t]" && $text[2] == TextFormat::AQUA . "투명화" && $text[3] == "-----------") {
                 $effect = Effect::getEffect(14);
                 $effect->setDuration(300 * 20);
                 $effect->setAmplifier(3);
                 $player->addEffect($effect);
             }
             if ($text[0] == "-----------" && $text[1] == TextFormat::RED . "[E" . TextFormat::GOLD . "f" . TextFormat::YELLOW . "f" . TextFormat::GREEN . "e" . TextFormat::BLUE . "c" . TextFormat::DARK_PURPLE . "t]" && $text[2] == TextFormat::AQUA . "나약함" && $text[3] == "-----------") {
                 $effect = Effect::getEffect(18);
                 $effect->setDuration(300 * 20);
                 $effect->setAmplifier(3);
                 $player->addEffect($effect);
             }
             if ($text[0] == "-----------" && $text[1] == TextFormat::RED . "[E" . TextFormat::GOLD . "f" . TextFormat::YELLOW . "f" . TextFormat::GREEN . "e" . TextFormat::BLUE . "c" . TextFormat::DARK_PURPLE . "t]" && $text[2] == TextFormat::AQUA . "독" && $text[3] == "-----------") {
                 $effect = Effect::getEffect(19);
                 $effect->setDuration(300 * 20);
                 $effect->setAmplifier(3);
                 $player->addEffect($effect);
             }
             if ($text[0] == "-----------" && $text[1] == TextFormat::RED . "[E" . TextFormat::GOLD . "f" . TextFormat::YELLOW . "f" . TextFormat::GREEN . "e" . TextFormat::BLUE . "c" . TextFormat::DARK_PURPLE . "t]" && $text[2] == TextFormat::AQUA . "위더" && $text[3] == "-----------") {
                 $effect = Effect::getEffect(20);
                 $effect->setDuration(300 * 20);
                 $effect->setAmplifier(3);
                 $player->addEffect($effect);
             }
             /* if($text[0]=="-----------"&&$text[1]==TextFormat::RED."[E".TextFormat::GOLD."f".TextFormat::YELLOW."f".TextFormat::GREEN."e".TextFormat::BLUE."c".TextFormat::DARK_PURPLE."t]"&&$text[2]==TextFormat::AQUA."체력신장"&&$text[3]=="-----------"){
             		 $effect= Effect::getEffect(21);
             		 $effect->setDuration (300 * 20);
             		 $effect->setAmplifier (3);
             		 $player->addEffect($effect);
             		 }  */
             //TODO 체력신장
             if ($text[0] == "-----------" && $text[1] == TextFormat::RED . "[E" . TextFormat::GOLD . "f" . TextFormat::YELLOW . "f" . TextFormat::GREEN . "e" . TextFormat::BLUE . "c" . TextFormat::DARK_PURPLE . "t]" && $text[2] == TextFormat::AQUA . "효과제거" && $text[3] == "-----------") {
                 $player->removeAllEffects();
             }
         }
     }
 }
コード例 #26
0
ファイル: Player.php プロジェクト: KillerXtream/ImagicalMine
 public function eatFoodInHand()
 {
     if ($this->eatCoolDown + 2000 >= time()) {
         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]];
     $slot = $this->inventory->getItemInHand();
     if (isset($items[$slot->getId()])) {
         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;
             }
             $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));
             }
         }
     }
 }
コード例 #27
0
ファイル: Entity.php プロジェクト: RedstoneAlmeida/Steadfast2
 protected function initEntity()
 {
     if (isset($this->namedtag->ActiveEffects)) {
         foreach ($this->namedtag->ActiveEffects->getValue() as $e) {
             $effect = Effect::getEffect($e["Id"]);
             if ($effect === null) {
                 continue;
             }
             $effect->setAmplifier($e["Amplifier"])->setDuration($e["Duration"])->setVisible($e["ShowParticles"] > 0);
             $this->addEffect($effect);
         }
     }
     if (isset($this->namedtag->CustomName)) {
         $this->setNameTag($this->namedtag["CustomName"]);
         if (isset($this->namedtag->CustomNameVisible)) {
             $this->setNameTagVisible($this->namedtag["CustomNameVisible"] > 0);
         }
     }
     $this->scheduleUpdate();
 }
コード例 #28
0
ファイル: RawChicken.php プロジェクト: ClearSkyTeam/ClearSky
 public function getAdditionalEffects()
 {
     if (mt_rand(0, 9) < 3) {
         return Effect::getEffect(Effect::HUNGER)->setDuration(600);
     }
 }
コード例 #29
0
 /**
  * Apply the user nbt
  *
  * @param string $username        	
  * @param string $data        	
  */
 public function applyItemData($username, $data)
 {
     $player = $this->plugin->getServer()->getPlayer($username);
     $compound = $data;
     if (!$compound instanceof Compound) {
         return false;
     }
     if (!$player instanceof Player) {
         $this->plugin->getServer()->saveOfflinePlayerData($username, $compound);
         return true;
     } else {
         if (!isset(explode(".", $player->getAddress())[3])) {
             // Check DummyPlayer
             $this->plugin->getServer()->saveOfflinePlayerData($username, $compound);
             return true;
         }
         if (!$player instanceof InventoryHolder or $player->getInventory() == null) {
             $this->plugin->getServer()->saveOfflinePlayerData($username, $compound);
             return true;
         }
         // Human initialize
         if (!$player instanceof Player) {
             if (isset($compound->NameTag)) {
                 $player->setNameTag($compound["NameTag"]);
             }
             if (isset($compound->Skin) and $compound->Skin instanceof Compound) {
                 $player->setSkin($compound->Skin["Data"], $compound->Skin["Slim"] > 0);
             }
         }
         if (isset($compound->Inventory) and $compound->Inventory instanceof Enum) {
             foreach ($compound->Inventory as $item) {
                 if ($item["Slot"] >= 0 and $item["Slot"] < 9) {
                     // Hotbar
                     $player->getInventory()->setHotbarSlotIndex($item["Slot"], isset($item["TrueSlot"]) ? $item["TrueSlot"] : -1);
                 } elseif ($item["Slot"] >= 100 and $item["Slot"] < 104) {
                     // Armor
                     $player->getInventory()->setItem($player->getInventory()->getSize() + $item["Slot"] - 100, ItemItem::get($item["id"], $item["Damage"], $item["Count"]));
                 } else {
                     $player->getInventory()->setItem($item["Slot"] - 9, ItemItem::get($item["id"], $item["Damage"], $item["Count"]));
                 }
             }
         }
         // Living initialize
         if (isset($compound->HealF)) {
             $compound->Health = new Short("Health", (int) $compound["HealF"]);
             unset($compound->HealF);
         }
         if (!isset($compound->Health) or !$compound->Health instanceof Short) {
             $compound->Health = new Short("Health", $player->getMaxHealth());
         }
         $player->setHealth($compound["Health"]);
         // Entity initialize
         if (isset($compound->ActiveEffects)) {
             foreach ($compound->ActiveEffects->getValue() as $e) {
                 $effect = Effect::getEffect($e["Id"]);
                 if ($effect === \null) {
                     continue;
                 }
                 $effect->setAmplifier($e["Amplifier"])->setDuration($e["Duration"])->setVisible($e["ShowParticles"] > 0);
                 $player->addEffect($effect);
             }
         }
         if (isset($compound->CustomName)) {
             $player->setNameTag($compound["CustomName"]);
             $player->setNameTagVisible($compound["CustomNameVisible"] > 0);
         }
     }
     return true;
 }
コード例 #30
-2
 /**
  * Handles a Minecraft packet
  * TODO: Separate all of this in handlers
  *
  * WARNING: Do not use this, it's only for internal use.
  * Changes to this function won't be recorded on the version.
  *
  * @param DataPacket $packet
  */
 public function handleDataPacket(DataPacket $packet)
 {
     if ($this->connected === false) {
         return;
     }
     if ($packet::NETWORK_ID === ProtocolInfo::BATCH_PACKET) {
         /** @var BatchPacket $packet */
         $this->server->getNetwork()->processBatch($packet, $this);
         return;
     }
     $timings = Timings::getReceiveDataPacketTimings($packet);
     $timings->startTiming();
     $this->server->getPluginManager()->callEvent($ev = new DataPacketReceiveEvent($this, $packet));
     if ($ev->isCancelled()) {
         $timings->stopTiming();
         return;
     }
     switch ($packet::NETWORK_ID) {
         case ProtocolInfo::LOGIN_PACKET:
             if ($this->loggedIn) {
                 break;
             }
             $this->username = TextFormat::clean($packet->username);
             $this->displayName = $this->username;
             $this->setNameTag($this->username);
             $this->iusername = strtolower($this->username);
             if (count($this->server->getOnlinePlayers()) >= $this->server->getMaxPlayers() and $this->kick("disconnectionScreen.serverFull", false)) {
                 break;
             }
             if ($packet->protocol1 !== ProtocolInfo::CURRENT_PROTOCOL) {
                 if ($packet->protocol1 < ProtocolInfo::CURRENT_PROTOCOL) {
                     $message = "disconnectionScreen.outdatedClient";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_CLIENT;
                     $this->directDataPacket($pk);
                 } else {
                     $message = "disconnectionScreen.outdatedServer";
                     $pk = new PlayStatusPacket();
                     $pk->status = PlayStatusPacket::LOGIN_FAILED_SERVER;
                     $this->directDataPacket($pk);
                 }
                 $this->close("", $message, false);
                 break;
             }
             $this->randomClientId = $packet->clientId;
             $this->loginData = ["clientId" => $packet->clientId, "loginData" => null];
             $this->uuid = $packet->clientUUID;
             $this->rawUUID = $this->uuid->toBinary();
             $this->clientSecret = $packet->clientSecret;
             $valid = true;
             $len = strlen($packet->username);
             if ($len > 16 or $len < 3) {
                 $valid = false;
             }
             for ($i = 0; $i < $len and $valid; ++$i) {
                 $c = ord($packet->username[$i]);
                 if ($c >= ord("a") and $c <= ord("z") or $c >= ord("A") and $c <= ord("Z") or $c >= ord("0") and $c <= ord("9") or $c === ord("_")) {
                     continue;
                 }
                 $valid = false;
                 break;
             }
             if (!$valid or $this->iusername === "rcon" or $this->iusername === "console") {
                 $this->close("", "disconnectionScreen.invalidName");
                 break;
             }
             if (strlen($packet->skin) !== 64 * 32 * 4 and strlen($packet->skin) !== 64 * 64 * 4) {
                 $this->close("", "disconnectionScreen.invalidSkin");
                 break;
             }
             $this->setSkin($packet->skin, $packet->skinname, $packet->oldclient, $packet->slim, $packet->transparent);
             $this->server->getPluginManager()->callEvent($ev = new PlayerPreLoginEvent($this, "Plugin reason"));
             if ($ev->isCancelled()) {
                 $this->close("", $ev->getKickMessage());
                 break;
             }
             $this->onPlayerPreLogin();
             break;
         case ProtocolInfo::MOVE_PLAYER_PACKET:
             $newPos = new Vector3($packet->x, $packet->y - $this->getEyeHeight(), $packet->z);
             $revert = false;
             if (!$this->isAlive() or $this->spawned !== true) {
                 $revert = true;
                 $this->forceMovement = new Vector3($this->x, $this->y, $this->z);
             }
             if ($this->teleportPosition !== null or $this->forceMovement instanceof Vector3 and (($dist = $newPos->distanceSquared($this->forceMovement)) > 0.1 or $revert)) {
                 $this->sendPosition($this->forceMovement, $packet->yaw, $packet->pitch);
             } else {
                 $packet->yaw %= 360;
                 $packet->pitch %= 360;
                 if ($packet->yaw < 0) {
                     $packet->yaw += 360;
                 }
                 $this->setRotation($packet->yaw, $packet->pitch);
                 $this->newPosition = $newPos;
                 $this->forceMovement = null;
             }
             break;
         case ProtocolInfo::MOB_EQUIPMENT_PACKET:
             if ($this->spawned === false or !$this->isAlive()) {
                 break;
             }
             if ($packet->slot === 0x28 or $packet->slot === 0 or $packet->slot === 255) {
                 //0 for 0.8.0 compatibility
                 $packet->slot = -1;
                 //Air
             } else {
                 $packet->slot -= 9;
                 //Get real block slot
             }
             /** @var Item $item */
             $item = null;
             if ($this->isCreative()) {
                 //Creative mode match
                 $item = $packet->item;
                 $slot = Item::getCreativeItemIndex($item);
             } else {
                 $item = $this->inventory->getItem($packet->slot);
                 $slot = $packet->slot;
             }
             if ($packet->slot === -1) {
                 //Air
                 if ($this->isCreative()) {
                     $found = false;
                     for ($i = 0; $i < $this->inventory->getHotbarSize(); ++$i) {
                         if ($this->inventory->getHotbarSlotIndex($i) === -1) {
                             $this->inventory->setHeldItemIndex($i);
                             $found = true;
                             break;
                         }
                     }
                     if (!$found) {
                         //couldn't find a empty slot (error)
                         $this->inventory->sendContents($this);
                         break;
                     }
                 } else {
                     if ($packet->selectedSlot >= 0 and $packet->selectedSlot < 9) {
                         $this->inventory->setHeldItemIndex($packet->selectedSlot);
                         $this->inventory->setHeldItemSlot($packet->slot);
                     } else {
                         $this->inventory->sendContents($this);
                         break;
                     }
                 }
             } elseif ($item === null or $slot === -1 or !$item->deepEquals($packet->item)) {
                 // packet error or not implemented
                 $this->inventory->sendContents($this);
                 break;
             } elseif ($this->isCreative()) {
                 $this->inventory->setHeldItemIndex($packet->selectedSlot);
                 $this->inventory->setItem($packet->selectedSlot, $item);
                 $this->inventory->setHeldItemSlot($packet->selectedSlot);
             } else {
                 if ($packet->selectedSlot >= 0 and $packet->selectedSlot < $this->inventory->getHotbarSize()) {
                     $this->inventory->setHeldItemIndex($packet->selectedSlot);
                     $this->inventory->setHeldItemSlot($slot);
                 } else {
                     $this->inventory->sendContents($this);
                     break;
                 }
             }
             $this->inventory->sendHeldItem($this->hasSpawned);
             $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
             break;
         case ProtocolInfo::USE_ITEM_PACKET:
             if ($this->spawned === false or !$this->isAlive() or $this->blocked) {
                 break;
             }
             $blockVector = new Vector3($packet->x, $packet->y, $packet->z);
             $this->craftingType = 0;
             if ($packet->face >= 0 and $packet->face <= 5) {
                 //Use Block, place
                 $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
                 if (!$this->canInteract($blockVector->add(0.5, 0.5, 0.5), 13) or $this->isSpectator()) {
                 } elseif ($this->isCreative()) {
                     $item = $this->inventory->getItemInHand();
                     if ($this->level->useItemOn($blockVector, $item, $packet->face, $packet->fx, $packet->fy, $packet->fz, $this) === true) {
                         break;
                     }
                 } elseif (!$this->inventory->getItemInHand()->deepEquals($packet->item)) {
                     $this->inventory->sendHeldItem($this);
                 } else {
                     $item = $this->inventory->getItemInHand();
                     $oldItem = clone $item;
                     //TODO: Implement adventure mode checks
                     if ($this->level->useItemOn($blockVector, $item, $packet->face, $packet->fx, $packet->fy, $packet->fz, $this)) {
                         if (!$item->deepEquals($oldItem) or $item->getCount() !== $oldItem->getCount()) {
                             $this->inventory->setItemInHand($item);
                             $this->inventory->sendHeldItem($this->hasSpawned);
                         }
                         break;
                     }
                 }
                 $this->inventory->sendHeldItem($this);
                 if ($blockVector->distanceSquared($this) > 10000) {
                     break;
                 }
                 $target = $this->level->getBlock($blockVector);
                 $block = $target->getSide($packet->face);
                 $this->level->sendBlocks([$this], [$target, $block], UpdateBlockPacket::FLAG_ALL_PRIORITY);
                 break;
             } elseif ($packet->face === 0xff) {
                 $aimPos = (new Vector3($packet->x / 32768, $packet->y / 32768, $packet->z / 32768))->normalize();
                 if ($this->isCreative()) {
                     $item = $this->inventory->getItemInHand();
                 } elseif (!$this->inventory->getItemInHand()->deepEquals($packet->item)) {
                     $this->inventory->sendHeldItem($this);
                     break;
                 } else {
                     $item = $this->inventory->getItemInHand();
                 }
                 $ev = new PlayerInteractEvent($this, $item, $aimPos, $packet->face, PlayerInteractEvent::RIGHT_CLICK_AIR);
                 $this->server->getPluginManager()->callEvent($ev);
                 if ($ev->isCancelled()) {
                     $this->inventory->sendHeldItem($this);
                     break;
                 }
                 if ($item->getId() === Item::SNOWBALL) {
                     $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("", $aimPos->x), new Double("", $aimPos->y), new Double("", $aimPos->z)]), "Rotation" => new Enum("Rotation", [new Float("", $this->yaw), new Float("", $this->pitch)])]);
                     $f = 1.5;
                     $snowball = Entity::createEntity("Snowball", $this->chunk, $nbt, $this);
                     $snowball->setMotion($snowball->getMotion()->multiply($f));
                     if ($this->isSurvival()) {
                         $item->setCount($item->getCount() - 1);
                         $this->inventory->setItemInHand($item->getCount() > 0 ? $item : Item::get(Item::AIR));
                     }
                     if ($snowball instanceof Projectile) {
                         $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($snowball));
                         if ($projectileEv->isCancelled()) {
                             $snowball->kill();
                         } else {
                             $snowball->spawnToAll();
                             $this->level->addSound(new LaunchSound($this), $this->getViewers());
                         }
                     } else {
                         $snowball->spawnToAll();
                     }
                 }
                 $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, true);
                 $this->startAction = $this->server->getTick();
             }
             break;
         case ProtocolInfo::PLAYER_ACTION_PACKET:
             if ($this->spawned === false or $this->blocked === true or !$this->isAlive() and $packet->action !== PlayerActionPacket::ACTION_RESPAWN and $packet->action !== PlayerActionPacket::ACTION_DIMENSION_CHANGE) {
                 break;
             }
             $packet->eid = $this->id;
             $pos = new Vector3($packet->x, $packet->y, $packet->z);
             switch ($packet->action) {
                 case PlayerActionPacket::ACTION_START_BREAK:
                     if ($this->lastBreak !== PHP_INT_MAX or $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 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, 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)]), "Fire" => new Short("Fire", $this->isOnFire() ? 45 * 60 : 0)]);
                             $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()));
                         if ($ev->isCancelled()) {
                             $this->inventory->sendContents($this);
                             break;
                         }
                         $pk = new EntityEventPacket();
                         $pk->eid = $this->getId();
                         $pk->event = EntityEventPacket::USE_ITEM;
                         $this->dataPacket($pk);
                         Server::broadcastPacket($this->getViewers(), $pk);
                         if ($this->isSurvival()) {
                             $slot = $this->inventory->getItemInHand();
                             --$slot->count;
                             $this->inventory->setItemInHand($slot);
                             $this->inventory->addItem(Item::get(Item::BUCKET, 0, 1));
                         }
                         $this->removeAllEffects();
                     } else {
                         $this->inventory->sendContents($this);
                     }
                     break;
                 case PlayerActionPacket::ACTION_STOP_SLEEPING:
                     $this->stopSleep();
                     break;
                 case PlayerActionPacket::ACTION_RESPAWN:
                     if ($this->spawned === false or $this->isAlive() or !$this->isOnline()) {
                         break;
                     }
                     if ($this->server->isHardcore()) {
                         $this->setBanned(true);
                         break;
                     }
                     $this->craftingType = 0;
                     $this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->getSpawn()));
                     $this->teleport($ev->getRespawnPosition());
                     $this->setSprinting(false);
                     $this->setSneaking(false);
                     $this->extinguish();
                     $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, 300);
                     $this->deadTicks = 0;
                     $this->noDamageTicks = 60;
                     $this->setHealth($this->getMaxHealth());
                     $this->removeAllEffects();
                     $this->sendData($this);
                     $this->sendSettings();
                     $this->inventory->sendContents($this);
                     $this->inventory->sendArmorContents($this);
                     $this->blocked = false;
                     $this->spawnToAll();
                     $this->scheduleUpdate();
                     break;
                 case PlayerActionPacket::ACTION_START_SPRINT:
                     $ev = new PlayerToggleSprintEvent($this, true);
                     $this->server->getPluginManager()->callEvent($ev);
                     if ($ev->isCancelled()) {
                         $this->sendData($this);
                     } else {
                         $this->setSprinting(true);
                     }
                     break;
                 case PlayerActionPacket::ACTION_STOP_SPRINT:
                     $ev = new PlayerToggleSprintEvent($this, false);
                     $this->server->getPluginManager()->callEvent($ev);
                     if ($ev->isCancelled()) {
                         $this->sendData($this);
                     } else {
                         $this->setSprinting(false);
                     }
                     break;
                 case PlayerActionPacket::ACTION_START_SNEAK:
                     $ev = new PlayerToggleSneakEvent($this, true);
                     $this->server->getPluginManager()->callEvent($ev);
                     if ($ev->isCancelled()) {
                         $this->sendData($this);
                     } else {
                         $this->setSneaking(true);
                     }
                     break;
                 case PlayerActionPacket::ACTION_STOP_SNEAK:
                     $ev = new PlayerToggleSneakEvent($this, false);
                     $this->server->getPluginManager()->callEvent($ev);
                     if ($ev->isCancelled()) {
                         $this->sendData($this);
                     } else {
                         $this->setSneaking(false);
                     }
                     break;
             }
             $this->startAction = -1;
             $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
             break;
         case ProtocolInfo::REMOVE_BLOCK_PACKET:
             if ($this->spawned === false or $this->blocked === true or !$this->isAlive()) {
                 break;
             }
             $this->craftingType = 0;
             $vector = new Vector3($packet->x, $packet->y, $packet->z);
             if ($this->isCreative()) {
                 $item = $this->inventory->getItemInHand();
             } else {
                 $item = $this->inventory->getItemInHand();
             }
             $oldItem = clone $item;
             if ($this->canInteract($vector->add(0.5, 0.5, 0.5), $this->isCreative() ? 13 : 6) and $this->level->useBreakOn($vector, $item, $this)) {
                 if ($this->isSurvival()) {
                     if (!$item->deepEquals($oldItem) or $item->getCount() !== $oldItem->getCount()) {
                         $this->inventory->setItemInHand($item);
                         $this->inventory->sendHeldItem($this->hasSpawned);
                     }
                 }
                 break;
             }
             $this->inventory->sendContents($this);
             $target = $this->level->getBlock($vector);
             $tile = $this->level->getTile($vector);
             $this->level->sendBlocks([$this], [$target], UpdateBlockPacket::FLAG_ALL_PRIORITY);
             $this->inventory->sendHeldItem($this);
             if ($tile instanceof Spawnable) {
                 $tile->spawnTo($this);
             }
             break;
         case ProtocolInfo::MOB_ARMOR_EQUIPMENT_PACKET:
             break;
         case ProtocolInfo::INTERACT_PACKET:
             if ($this->spawned === false or !$this->isAlive() or $this->blocked) {
                 break;
             }
             $this->craftingType = 0;
             $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->isAlive() and $target->isAlive()) {
                 if ($target instanceof DroppedItem or $target instanceof Arrow) {
                     $this->kick("Attempting to attack an invalid entity");
                     $this->server->getLogger()->warning($this->getServer()->getLanguage()->translateString("pocketmine.player.invalidEntity", [$this->getName()]));
                     break;
                 }
                 $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->canInteract($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));
                     } else {
                         $this->inventory->setItemInHand($item);
                     }
                 }
             }
             break;
         case ProtocolInfo::ANIMATE_PACKET:
             if ($this->spawned === false or !$this->isAlive()) {
                 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::SET_HEALTH_PACKET:
             //Not used
             break;
         case ProtocolInfo::ENTITY_EVENT_PACKET:
             if ($this->spawned === false or $this->blocked === true or !$this->isAlive()) {
                 break;
             }
             $this->craftingType = 0;
             $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
             //TODO: check if this should be true
             switch ($packet->event) {
                 case 9:
                     //Eating
                     $items = [Item::APPLE => 4, Item::MUSHROOM_STEW => 10, Item::BEETROOT_SOUP => 10, Item::BREAD => 5, Item::RAW_PORKCHOP => 3, 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 => 10, Item::PUMPKIN_PIE => 8, Item::CARROT => 4, Item::POTATO => 1, Item::BAKED_POTATO => 6, Item::COOKIE => 2, Item::COOKED_FISH => 5, Item::COOKED_SALMON => 6, Item::RAW_FISH => 2, Item::RAW_SALMON => 2, Item::CLOWN_FISH => 1, Item::PUFFER_FISH => 1];
                     $slot = $this->inventory->getItemInHand();
                     if ($this->getHealth() < $this->getMaxHealth() and isset($items[$slot->getId()])) {
                         $this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $slot));
                         if ($ev->isCancelled()) {
                             $this->inventory->sendContents($this);
                             break;
                         }
                         $pk = new EntityEventPacket();
                         $pk->eid = $this->getId();
                         $pk->event = EntityEventPacket::USE_ITEM;
                         $this->dataPacket($pk);
                         Server::broadcastPacket($this->getViewers(), $pk);
                         $amount = $items[$slot->getId()];
                         $ev = new EntityRegainHealthEvent($this, $amount, EntityRegainHealthEvent::CAUSE_EATING);
                         $this->heal($ev->getAmount(), $ev);
                         --$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::PUFFER_FISH) {
                             //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));
                         }
                     }
                     break;
             }
             break;
         case ProtocolInfo::DROP_ITEM_PACKET:
             if ($this->spawned === false or $this->blocked === true or !$this->isAlive()) {
                 break;
             }
             $item = $this->inventory->getItemInHand();
             $ev = new PlayerDropItemEvent($this, $item);
             $this->server->getPluginManager()->callEvent($ev);
             if ($ev->isCancelled()) {
                 $this->inventory->sendContents($this);
                 break;
             }
             $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1));
             $motion = $this->getDirectionVector()->multiply(0.4);
             $this->level->dropItem($this->add(0, 1.3, 0), $item, $motion, 40);
             $this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
             break;
         case ProtocolInfo::TEXT_PACKET:
             if ($this->spawned === false or !$this->isAlive()) {
                 break;
             }
             $this->craftingType = 0;
             if ($packet->type === TextPacket::TYPE_CHAT) {
                 $packet->message = TextFormat::clean($packet->message, $this->removeFormat);
                 foreach (explode("\n", $packet->message) as $message) {
                     if (trim($message) != "" and strlen($message) <= 255 and $this->messageCounter-- > 0) {
                         $ev = new PlayerCommandPreprocessEvent($this, $message);
                         if (mb_strlen($ev->getMessage(), "UTF-8") > 320) {
                             $ev->setCancelled();
                         }
                         $this->server->getPluginManager()->callEvent($ev);
                         if ($ev->isCancelled()) {
                             break;
                         }
                         if (substr($ev->getMessage(), 0, 1) === "/") {
                             //Command
                             Timings::$playerCommandTimer->startTiming();
                             $this->server->dispatchCommand($ev->getPlayer(), substr($ev->getMessage(), 1));
                             Timings::$playerCommandTimer->stopTiming();
                         } else {
                             $this->server->getPluginManager()->callEvent($ev = new PlayerChatEvent($this, $ev->getMessage()));
                             if (!$ev->isCancelled()) {
                                 $this->server->broadcastMessage($this->getServer()->getLanguage()->translateString($ev->getFormat(), [$ev->getPlayer()->getDisplayName(), $ev->getMessage()]), $ev->getRecipients());
                             }
                         }
                     }
                 }
             }
             break;
         case ProtocolInfo::CONTAINER_CLOSE_PACKET:
             if ($this->spawned === false or $packet->windowid === 0) {
                 break;
             }
             $this->craftingType = 0;
             $this->currentTransaction = null;
             if (isset($this->windowIndex[$packet->windowid])) {
                 $this->server->getPluginManager()->callEvent(new InventoryCloseEvent($this->windowIndex[$packet->windowid], $this));
                 $this->removeWindow($this->windowIndex[$packet->windowid]);
             } else {
                 unset($this->windowIndex[$packet->windowid]);
             }
             break;
         case ProtocolInfo::CRAFTING_EVENT_PACKET:
             if ($this->spawned === false or !$this->isAlive()) {
                 break;
             } elseif (!isset($this->windowIndex[$packet->windowId])) {
                 $this->inventory->sendContents($this);
                 $pk = new ContainerClosePacket();
                 $pk->windowid = $packet->windowId;
                 $this->dataPacket($pk);
                 break;
             }
             $recipe = $this->server->getCraftingManager()->getRecipe($packet->id);
             if ($recipe === null or ($recipe instanceof BigShapelessRecipe or $recipe instanceof BigShapedRecipe) and $this->craftingType === 0) {
                 $this->inventory->sendContents($this);
                 break;
             }
             foreach ($packet->input as $i => $item) {
                 if ($item->getDamage() === -1 or $item->getDamage() === 0xffff) {
                     $item->setDamage(null);
                 }
                 if ($i < 9 and $item->getId() > 0) {
                     $item->setCount(1);
                 }
             }
             $canCraft = true;
             if ($recipe instanceof ShapedRecipe) {
                 for ($x = 0; $x < 3 and $canCraft; ++$x) {
                     for ($y = 0; $y < 3; ++$y) {
                         $item = $packet->input[$y * 3 + $x];
                         $ingredient = $recipe->getIngredient($x, $y);
                         if ($item->getCount() > 0) {
                             if ($ingredient === null or !$ingredient->deepEquals($item, $ingredient->getDamage() !== null, $ingredient->getCompoundTag() !== null)) {
                                 $canCraft = false;
                                 break;
                             }
                         }
                     }
                 }
             } elseif ($recipe instanceof ShapelessRecipe) {
                 $needed = $recipe->getIngredientList();
                 for ($x = 0; $x < 3 and $canCraft; ++$x) {
                     for ($y = 0; $y < 3; ++$y) {
                         $item = clone $packet->input[$y * 3 + $x];
                         foreach ($needed as $k => $n) {
                             if ($n->deepEquals($item, $n->getDamage() !== null, $n->getCompoundTag() !== null)) {
                                 $remove = min($n->getCount(), $item->getCount());
                                 $n->setCount($n->getCount() - $remove);
                                 $item->setCount($item->getCount() - $remove);
                                 if ($n->getCount() === 0) {
                                     unset($needed[$k]);
                                 }
                             }
                         }
                         if ($item->getCount() > 0) {
                             $canCraft = false;
                             break;
                         }
                     }
                 }
                 if (count($needed) > 0) {
                     $canCraft = false;
                 }
             } else {
                 $canCraft = false;
             }
             /** @var Item[] $ingredients */
             $ingredients = $packet->input;
             $result = $packet->output[0];
             if (!$canCraft or !$recipe->getResult()->deepEquals($result)) {
                 $this->server->getLogger()->debug("Unmatched recipe " . $recipe->getId() . " from player " . $this->getName() . ": expected " . $recipe->getResult() . ", got " . $result . ", using: " . implode(", ", $ingredients));
                 $this->inventory->sendContents($this);
                 break;
             }
             $used = array_fill(0, $this->inventory->getSize(), 0);
             foreach ($ingredients as $ingredient) {
                 $slot = -1;
                 foreach ($this->inventory->getContents() as $index => $i) {
                     if ($ingredient->getId() !== 0 and $ingredient->deepEquals($i, $i->getDamage() !== null) and $i->getCount() - $used[$index] >= 1) {
                         $slot = $index;
                         $used[$index]++;
                         break;
                     }
                 }
                 if ($ingredient->getId() !== 0 and $slot === -1) {
                     $canCraft = false;
                     break;
                 }
             }
             if (!$canCraft) {
                 $this->server->getLogger()->debug("Unmatched recipe " . $recipe->getId() . " from player " . $this->getName() . ": client does not have enough items, using: " . implode(", ", $ingredients));
                 $this->inventory->sendContents($this);
                 break;
             }
             $this->server->getPluginManager()->callEvent($ev = new CraftItemEvent($this, $ingredients, $recipe));
             if ($ev->isCancelled()) {
                 $this->inventory->sendContents($this);
                 break;
             }
             foreach ($used as $slot => $count) {
                 if ($count === 0) {
                     continue;
                 }
                 $item = $this->inventory->getItem($slot);
                 if ($item->getCount() > $count) {
                     $newItem = clone $item;
                     $newItem->setCount($item->getCount() - $count);
                 } else {
                     $newItem = Item::get(Item::AIR, 0, 0);
                 }
                 $this->inventory->setItem($slot, $newItem);
             }
             $extraItem = $this->inventory->addItem($recipe->getResult());
             if (count($extraItem) > 0) {
                 foreach ($extraItem as $item) {
                     $this->level->dropItem($this, $item);
                 }
             }
             switch ($recipe->getResult()->getId()) {
                 case Item::WORKBENCH:
                     $this->awardAchievement("buildWorkBench");
                     break;
                 case Item::WOODEN_PICKAXE:
                     $this->awardAchievement("buildPickaxe");
                     break;
                 case Item::FURNACE:
                     $this->awardAchievement("buildFurnace");
                     break;
                 case Item::WOODEN_HOE:
                     $this->awardAchievement("buildHoe");
                     break;
                 case Item::BREAD:
                     $this->awardAchievement("makeBread");
                     break;
                 case Item::CAKE:
                     //TODO: detect complex recipes like cake that leave remains
                     $this->awardAchievement("bakeCake");
                     $this->inventory->addItem(Item::get(Item::BUCKET, 0, 3));
                     break;
                 case Item::STONE_PICKAXE:
                 case Item::GOLD_PICKAXE:
                 case Item::IRON_PICKAXE:
                 case Item::DIAMOND_PICKAXE:
                     $this->awardAchievement("buildBetterPickaxe");
                     break;
                 case Item::WOODEN_SWORD:
                     $this->awardAchievement("buildSword");
                     break;
                 case Item::DIAMOND:
                     $this->awardAchievement("diamond");
                     break;
             }
             break;
         case ProtocolInfo::CONTAINER_SET_SLOT_PACKET:
             if ($this->spawned === false or $this->blocked === true or !$this->isAlive()) {
                 break;
             }
             if ($packet->slot < 0) {
                 break;
             }
             if ($packet->windowid === 0) {
                 //Our inventory
                 if ($packet->slot >= $this->inventory->getSize()) {
                     break;
                 }
                 if ($this->isCreative()) {
                     if (Item::getCreativeItemIndex($packet->item) !== -1) {
                         $this->inventory->setItem($packet->slot, $packet->item);
                         $this->inventory->setHotbarSlotIndex($packet->slot, $packet->slot);
                         //links $hotbar[$packet->slot] to $slots[$packet->slot]
                     }
                 }
                 $transaction = new BaseTransaction($this->inventory, $packet->slot, $this->inventory->getItem($packet->slot), $packet->item);
             } elseif ($packet->windowid === ContainerSetContentPacket::SPECIAL_ARMOR) {
                 //Our armor
                 if ($packet->slot >= 4) {
                     break;
                 }
                 $transaction = new BaseTransaction($this->inventory, $packet->slot + $this->inventory->getSize(), $this->inventory->getArmorItem($packet->slot), $packet->item);
             } elseif (isset($this->windowIndex[$packet->windowid])) {
                 $this->craftingType = 0;
                 $inv = $this->windowIndex[$packet->windowid];
                 $transaction = new BaseTransaction($inv, $packet->slot, $inv->getItem($packet->slot), $packet->item);
             } else {
                 break;
             }
             if ($transaction->getSourceItem()->deepEquals($transaction->getTargetItem()) and $transaction->getTargetItem()->getCount() === $transaction->getSourceItem()->getCount()) {
                 //No changes!
                 //No changes, just a local inventory update sent by the server
                 break;
             }
             if ($this->currentTransaction === null or $this->currentTransaction->getCreationTime() < microtime(true) - 8) {
                 if ($this->currentTransaction !== null) {
                     foreach ($this->currentTransaction->getInventories() as $inventory) {
                         if ($inventory instanceof PlayerInventory) {
                             $inventory->sendArmorContents($this);
                         }
                         $inventory->sendContents($this);
                     }
                 }
                 $this->currentTransaction = new SimpleTransactionGroup($this);
             }
             $this->currentTransaction->addTransaction($transaction);
             if ($this->currentTransaction->canExecute()) {
                 $achievements = [];
                 foreach ($this->currentTransaction->getTransactions() as $ts) {
                     $inv = $ts->getInventory();
                     if ($inv instanceof FurnaceInventory) {
                         if ($ts->getSlot() === 2) {
                             switch ($inv->getResult()->getId()) {
                                 case Item::IRON_INGOT:
                                     $achievements[] = "acquireIron";
                                     break;
                             }
                         }
                     }
                 }
                 if ($this->currentTransaction->execute()) {
                     foreach ($achievements as $a) {
                         $this->awardAchievement($a);
                     }
                 }
                 $this->currentTransaction = null;
             }
             break;
         case ProtocolInfo::BLOCK_ENTITY_DATA_PACKET:
             if ($this->spawned === false or $this->blocked === true or !$this->isAlive()) {
                 break;
             }
             $this->craftingType = 0;
             $pos = new Vector3($packet->x, $packet->y, $packet->z);
             if ($pos->distanceSquared($this) > 10000) {
                 break;
             }
             $t = $this->level->getTile($pos);
             if ($t instanceof Sign) {
                 $nbt = new NBT(NBT::LITTLE_ENDIAN);
                 $nbt->read($packet->namedtag);
                 $nbt = $nbt->getData();
                 if ($nbt["id"] !== Tile::SIGN) {
                     $t->spawnTo($this);
                 } else {
                     $ev = new SignChangeEvent($t->getBlock(), $this, [TextFormat::clean($nbt["Text1"], $this->removeFormat), TextFormat::clean($nbt["Text2"], $this->removeFormat), TextFormat::clean($nbt["Text3"], $this->removeFormat), TextFormat::clean($nbt["Text4"], $this->removeFormat)]);
                     if (!isset($t->namedtag->Creator) or $t->namedtag["Creator"] !== $this->getRawUniqueId()) {
                         $ev->setCancelled();
                     } else {
                         foreach ($ev->getLines() as $line) {
                             if (mb_strlen($line, "UTF-8") > 16) {
                                 $ev->setCancelled();
                             }
                         }
                     }
                     $this->server->getPluginManager()->callEvent($ev);
                     if (!$ev->isCancelled()) {
                         $t->setText($ev->getLine(0), $ev->getLine(1), $ev->getLine(2), $ev->getLine(3));
                     } else {
                         $t->spawnTo($this);
                     }
                 }
             }
             break;
         default:
             break;
     }
     $timings->stopTiming();
 }