Inheritance: extends PlayerEvent, implements pocketmine\event\Cancellable
Ejemplo n.º 1
2
 /**
  * @param PlayerItemHeldEvent $event
  * @priority HIGH
  */
 public function h_onItemHeld(PlayerItemHeldEvent $event)
 {
     $player = $event->getPlayer();
     if (isset($this->sessions[$o = Session::offset($player)])) {
         $this->sessions[$o]->h_onItemHeld($event);
     }
 }
Ejemplo n.º 2
1
 public function onHold(PlayerItemHeldEvent $event)
 {
     if ($this->config->get("PlayerItemHeldEvent", true)) {
         $player = $event->getPlayer();
         if ($event->getItem()->getId() == 46) {
             $player->sendPopup(TextFormat::AQUA . $this->prefix . "Your Inventory Clearing...");
             $player->getInventory()->clearAll();
             $player->getLevel()->addSound(new PopSound($player));
         }
         if ($event->getItem()->getId() == 347) {
             $player->sendPopup("§aReturn to Hub!");
             $x = $player->x;
             $y = $player->y;
             $z = $player->z;
             $player->getLevel()->addSound(new PopSound($player));
             $player->getLevel()->addParticle(new FlameParticle(new Vector3($x, $y, $z)));
             $player->getLevel()->addParticle(new FlameParticle(new Vector3($x + 1, $y + 1, $z + 1)));
             $player->getLevel()->addParticle(new FlameParticle(new Vector3($x + 2, $y + 2, $z + 2)));
             $player->getLevel()->addParticle(new FlameParticle(new Vector3($x + 3, $y + 3, $z + 3)));
             $player->getLevel()->addParticle(new FlameParticle(new Vector3($x + 4, $y + 4, $z + 4)));
             $player->getLevel()->addParticle(new FlameParticle(new Vector3($x + 5, $y + 5, $z + 5)));
         }
     }
 }
Ejemplo n.º 3
1
 public function setHeldItemSlot($slot)
 {
     if ($slot >= -1 and $slot < $this->getSize()) {
         $item = $this->getItem($slot);
         if ($this->getHolder() instanceof Player) {
             Server::getInstance()->getPluginManager()->callEvent($ev = new PlayerItemHeldEvent($this->getHolder(), $item, $slot, $this->itemInHandIndex));
             if ($ev->isCancelled()) {
                 $this->sendHeldItem($this->getHolder());
                 return;
             }
         }
         $this->setHotbarSlotIndex($this->itemInHandIndex, $slot);
         $this->sendHeldItem($this->getHolder()->getViewers());
     }
 }
 public function onItemHold(PlayerItemHeldEvent $event)
 {
     $player = $event->getPlayer();
     if ($event->getItem()->getId() == $this->config->get("Energy-Item-ID")) {
         $this->reduceEnergy($player);
     }
 }
Ejemplo n.º 5
0
 /**
  * @priority MONITOR
  */
 public function onItemHeld(PlayerItemHeldEvent $event)
 {
     $player = $event->getPlayer();
     $item = $event->getItem();
     if ($player->isCreative()) {
         return;
     }
     if (!$this->isAllowedWorld($player->getLevel())) {
         return;
     }
     if ($event->isCancelled() || $this->auth !== null && !$this->auth->isPlayerAuthenticated($player)) {
         return;
     }
     foreach ($this->getConfig()->get("data") as $slot => $g) {
         if ($item->getId() === $g["id"] && $item->getDamage() === $g["damage"]) {
             foreach ($g["command"] as $cmd) {
                 $popup = $g["popup"];
                 $player->sendPopup($popup);
                 if (!empty($cmd)) {
                     $this->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("{player}", $player->getName(), str_replace("/", "", $cmd)));
                 }
             }
         }
     }
 }
Ejemplo n.º 6
0
 public function onItemHeld(PlayerItemHeldEvent $event)
 {
     $item = $event->getItem();
     if ($item->getId() === Item::SHEARS) {
         $player = $event->getPlayer();
         $player->sendPopup(TextFormat::GREEN . "Hit a sheep with your shears to shear sheep.");
     }
 }
Ejemplo n.º 7
0
 public function onItemHeld(PlayerItemHeldEvent $e)
 {
     $pl = $e->getPlayer();
     if (!$this->owner->getState("CloakClock", $pl, false)) {
         return;
     }
     if ($e->getItem()->getId() != $this->item) {
         $this->deactivate($pl);
     }
 }
Ejemplo n.º 8
0
 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);
     }
 }
Ejemplo n.º 9
0
 public function onItemHeld(PlayerItemHeldEvent $e)
 {
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     $pl = $e->getPlayer();
     if (!$this->owner->getState("Torch", $pl, null)) {
         return;
     }
     if ($e->getItem()->getId() != $this->item) {
         $this->deSpawnTorch($pl);
     }
 }
Ejemplo n.º 10
0
 public function onHeld(PlayerItemHeldEvent $event)
 {
     $cfg = $this->getConfig();
     $playername = $event->getPlayer()->getName();
     $item = $event->getItem()->getId();
     if ($item === $cfg->get("Item-1") and $cfg->get("Enable-1") == true) {
         foreach ($cfg->get("Command-1") as $cmd1) {
             $this->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("{player}", $playername, $cmd1));
         }
     } elseif ($item === $cfg->get("Item-2") and $cfg->get("Enable-2") == true) {
         foreach ($cfg->get("Command-2") as $cmd2) {
             $this->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("{player}", $playername, $cmd2));
         }
     } elseif ($item === $cfg->get("Item-3") and $cfg->get("Enable-3") == true) {
         foreach ($cfg->get("Command-3") as $cmd3) {
             $this->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("{player}", $playername, $cmd3));
         }
     } elseif ($item === $cfg->get("Item-4") and $cfg->get("Enable-4") == true) {
         foreach ($cfg->get("Command-4") as $cmd4) {
             $this->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("{player}", $playername, $cmd4));
         }
     } elseif ($item === $cfg->get("Item-5") and $cfg->get("Enable-5") == true) {
         foreach ($cfg->get("Command-5") as $cmd5) {
             $this->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("{player}", $playername, $cmd5));
         }
     } elseif ($item === $cfg->get("Item-6") and $cfg->get("Enable-6") == true) {
         foreach ($cfg->get("Command-6") as $cmd6) {
             $this->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("{player}", $playername, $cmd6));
         }
     } elseif ($item === $cfg->get("Item-7") and $cfg->get("Enable-7") == true) {
         foreach ($cfg->get("Command-7") as $cmd6) {
             $this->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("{player}", $playername, $cmd7));
         }
     } elseif ($item === $cfg->get("Item-8") and $cfg->get("Enable-8") == true) {
         foreach ($cfg->get("Command-8") as $cmd6) {
             $this->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("{player}", $playername, $cmd8));
         }
     } elseif ($item === $cfg->get("Item-9") and $cfg->get("Enable-9") == true) {
         foreach ($cfg->get("Command-9") as $cmd6) {
             $this->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("{player}", $playername, $cmd9));
         }
     } elseif ($item === $cfg->get("Item-10") and $cfg->get("Enable-10") == true) {
         foreach ($cfg->get("Command-10") as $cmd6) {
             $this->getServer()->dispatchCommand(new ConsoleCommandSender(), str_replace("{player}", $playername, $cmd10));
         }
     }
 }
Ejemplo n.º 11
0
 public function onHeld(PlayerItemHeldEvent $event)
 {
     $cfg = $this->getConfig();
     $player = $event->getPlayer();
     $hidetask = new PlayerHideTask($this, $player);
     $item = $event->getItem()->getId();
     switch ($item) {
         case $cfg->get("HidePlayers-Item"):
             $this->task = $this->getServer()->getScheduler()->scheduleRepeatingTask($hidetask, 20);
             $player->sendPopup(TextFormat::YELLOW . $cfg->get("HidePlayer-Message"));
             $event->setCancelled(true);
             break;
         case $cfg->get("ShowPlayers-Item"):
             $this->getServer()->getScheduler()->cancelTask($this->task->getTaskId());
             foreach ($this->getServer()->getOnlinePlayers() as $onl) {
                 $player->showPlayer($onl);
                 $player->sendPopup(TextFormat::GREEN . $cfg->get("ShowPlayer-Message"));
                 $event->setCancelled(true);
             }
             break;
     }
 }
Ejemplo n.º 12
0
 public function PlayerItemHeldEvent(PlayerItemHeldEvent $event)
 {
     $i = $event->getItem();
     $p = $event->getPlayer();
     if ($i->getId() == 35 && $i->getDamage() == 5) {
         $p->sendMessage(TextFormat::GREEN . "Вы успешно оставили голос!");
         $p->sendTip(TextFormat::GREEN . "Вы успешно оставили голос!");
         $event->setCancelled(true);
         if ($this->bb[12] == "1") {
             $this->bb[2] = (int) $this->bb[2] + 3;
         } elseif ($this->bb[12] == "2") {
             $this->bb[3] = (int) $this->bb[2] + 3;
         } elseif ($this->bb[12] == "3") {
             $this->bb[4] = (int) $this->bb[2] + 3;
         } elseif ($this->bb[12] == "4") {
             $this->bb[5] = (int) $this->bb[2] + 3;
         } elseif ($this->bb[12] == "5") {
             $this->bb[6] = (int) $this->bb[2] + 3;
         }
         $event->getPlayer()->getInventory()->addItem(Item::get(1, 0, 1));
         $p->getInventory()->clearAll();
     } elseif ($i->getId() == 35 && $i->getDamage() == 4) {
         $p->sendMessage(TextFormat::YELLOW . "Вы успешно оставили голос!");
         $p->sendTip(TextFormat::YELLOW . "Вы успешно оставили голос!");
         $event->setCancelled(true);
         if ($this->bb[12] == "1") {
             $this->bb[2] = (int) $this->bb[2] + 2;
         } elseif ($this->bb[12] == "2") {
             $this->bb[3] = (int) $this->bb[2] + 2;
         } elseif ($this->bb[12] == "3") {
             $this->bb[4] = (int) $this->bb[2] + 2;
         } elseif ($this->bb[12] == "4") {
             $this->bb[5] = (int) $this->bb[2] + 2;
         } elseif ($this->bb[12] == "5") {
             $this->bb[6] = (int) $this->bb[2] + 2;
         }
         $event->getPlayer()->getInventory()->addItem(Item::get(1, 0, 1));
         $p->getInventory()->clearAll();
     } elseif ($i->getId() == 35 && $i->getDamage() == 14) {
         $p->sendMessage(TextFormat::RED . "Вы успешно оставили голос!");
         $p->sendTip(TextFormat::RED . "Вы успешно оставили голос!");
         $event->setCancelled(true);
         if ($this->bb[12] == "1") {
             $this->bb[2] = (int) $this->bb[2] + 1;
         } elseif ($this->bb[12] == "2") {
             $this->bb[3] = (int) $this->bb[2] + 1;
         } elseif ($this->bb[12] == "3") {
             $this->bb[4] = (int) $this->bb[2] + 1;
         } elseif ($this->bb[12] == "4") {
             $this->bb[5] = (int) $this->bb[2] + 1;
         } elseif ($this->bb[12] == "5") {
             $this->bb[6] = (int) $this->bb[2] + 1;
         }
         $event->getPlayer()->getInventory()->addItem(Item::get(1, 0, 1));
         $p->getInventory()->clearAll();
     }
 }
Ejemplo n.º 13
0
 public function onPlayerItemHeld(PlayerItemHeldEvent $event)
 {
     $Player = $event->getPlayer();
     $Level = $Player->getLevel();
     if (!$this->plugin->game || $this->plugin->game->level_name != $Level->getFolderName()) {
         return;
     }
     $HandItem = $event->getItem();
     $X = $Player->getFloorX();
     $Y = $Player->getFloorY() - 1;
     $Z = $Player->getFloorZ();
     $Block = $Level->getBlock(new Vector3($X, $Y, $Z));
     if ($HandItem->getId() == 341 && $Block->getId() == 0) {
         $SlimeX = $X;
         $SlimeY = $Y - 2;
         $SlimeZ = $Z;
         for ($x = $SlimeX - 2; $x <= $SlimeX + 2; $x++) {
             for ($z = $SlimeZ - 2; $z <= $SlimeZ + 2; $z++) {
                 if ($Level->getBlockIdAt($x, $SlimeY, $z) == 0) {
                     $Level->setBlockIdAt($x, $SlimeY, $z, 133);
                     $this->plugin->game->BlocksPlaced[] = new Vector3($x, $SlimeY, $z);
                 }
             }
         }
         $HandItem->setCount($HandItem->getCount() - 1);
         $Player->getInventory()->setItemInHand($HandItem);
         $Player->setMotion(new Vector3(0, 0.2, 0));
     }
 }
Ejemplo n.º 14
0
 public function h_onItemHeld(PlayerItemHeldEvent $event)
 {
     switch ($this->getInventorySession()) {
         case self::INV_CHOOSE_GAME:
             $event->setCancelled();
             $slot = $event->getInventorySlot();
             $gameId = $slot | self::SES_STATE_GAME;
             if ($gameId === $this->session) {
                 $this->tell("You are already here!");
                 return;
             }
             $this->setInventorySession(self::INV_NORMAL_ACCESS);
             $game = $this->getGame();
             if ($game instanceof Game) {
                 $game->onQuit($this, false);
                 $this->unsubscribeFromChannel($game->getDefaultChatChannel());
             }
             $this->getPlayer()->getInventory()->clearAll();
             if ($gameId === self::SESSION_GAME_HUB) {
                 $this->switchSession(self::SESSION_GAME_HUB);
             } else {
                 $game = $this->main->getGame($gameId);
                 if (!$game instanceof Game) {
                     return;
                 }
                 if (!$this->joinGame($game)) {
                     $this->tell("This game is not available!");
                     $this->setInventorySession(self::INV_CHOOSE_GAME);
                 }
             }
             break;
     }
 }
Ejemplo n.º 15
0
 public function onItemHeld(PlayerItemHeldEvent $ev)
 {
     if ($ev->getItem()->getId() == Item::AIR) {
         return;
     }
     $this->sendPopup($ev->getPlayer(), ItemName::str($ev->getItem()), 2);
 }
Ejemplo n.º 16
0
 public function onHold(PlayerItemHeldEvent $event)
 {
     $item = $event->getItem();
     $player = $event->getPlayer();
     if ($item instanceof Bow) {
         if (!is_file($this->getDataFolder() . $player->getName() . ".json")) {
             return true;
         }
         $data = file_get_contents($this->getDataFolder() . $player->getName() . ".json");
         $decode = json_decode($data, true);
         if (isset($decode["annihilator"])) {
             if ($decode["annihilator"] != "yes") {
                 return true;
             }
             $player->sendMessage(TextFormat::BLUE . ">> " . TextFormat::RED . "Annihilator " . TextFormat::BLUE . " <<");
             return true;
         }
     }
 }
 /**
  * @param PlayerItemHeldEvent $event 
  * @priority HIGHEST
  * @ignoreCancelled true
  */
 public function onPlayerItemHeld(PlayerItemHeldEvent $event)
 {
     if ($this->plugin->getStorage()->getShield($event->getPlayer()->getLevel())->isItemBanned($event->getItem())) {
         $event->setCancelled(true);
         $event->getPlayer()->sendTip($this->plugin->getConfig()->get("itemNotAllowed"));
     }
 }
Ejemplo n.º 18
0
 /**
  * @param int  $hotbarSlotIndex
  * @param bool $sendToHolder
  * @param int  $slotMapping
  *
  * Sets which hotbar slot the player is currently holding.
  * Allows slot remapping as specified by a MobEquipmentPacket. DO NOT CHANGE SLOT MAPPING IN PLUGINS!
  * This new implementation is fully compatible with older APIs.
  * NOTE: Slot mapping is the raw slot index sent by MCPE, which will be between 9 and 44.
  */
 public function setHeldItemIndex($hotbarSlotIndex, $sendToHolder = true, $slotMapping = null)
 {
     if ($slotMapping !== null) {
         //Get the index of the slot in the actual inventory
         $slotMapping -= $this->getHotbarSize();
     }
     if (0 <= $hotbarSlotIndex and $hotbarSlotIndex < $this->getHotbarSize()) {
         $this->itemInHandIndex = $hotbarSlotIndex;
         if ($slotMapping !== null) {
             /* Handle a hotbar slot mapping change. This allows PE to select different inventory slots.
              * This is the only time slot mapping should ever be changed. */
             if ($slotMapping < 0 or $slotMapping >= $this->getSize()) {
                 //Mapping was not in range of the inventory, set it to -1
                 //This happens if the client selected a blank slot (sends 255)
                 $slotMapping = -1;
             }
             $item = $this->getItem($slotMapping);
             if ($this->getHolder() instanceof Player) {
                 Server::getInstance()->getPluginManager()->callEvent($ev = new PlayerItemHeldEvent($this->getHolder(), $item, $slotMapping, $hotbarSlotIndex));
                 if ($ev->isCancelled()) {
                     $this->sendHeldItem($this->getHolder());
                     $this->sendContents($this->getHolder());
                     return;
                 }
             }
             if (($key = array_search($slotMapping, $this->hotbar)) !== false and $slotMapping !== -1) {
                 /* Do not do slot swaps if the slot was null
                  * Chosen slot is already linked to a hotbar slot, swap the two slots around.
                  * This will already have been done on the client-side so no changes need to be sent. */
                 $this->hotbar[$key] = $this->hotbar[$this->itemInHandIndex];
             }
             $this->hotbar[$this->itemInHandIndex] = $slotMapping;
         }
         $this->sendHeldItem($this->getHolder()->getViewers());
         if ($sendToHolder) {
             $this->sendHeldItem($this->getHolder());
         }
     }
 }
Ejemplo n.º 19
0
 public function onItemHeld(PlayerItemHeldEvent $e)
 {
     $pl = $e->getPlayer();
     $n = $pl->getName();
     if (!isset($this->players[$n])) {
         return;
     }
     $hand = $pl->getInventory()->getItemInHand();
     if ($hand->getId() != $this->cf["sword1"] && $hand->getId() != $this->cf["sword2"]) {
         $pl->sendMessage("Flame Off!");
         unset($this->players[$n]);
     }
 }
Ejemplo n.º 20
-1
 public function heldItems(PlayerItemHeldEvent $e)
 {
     //For Ease of access for other functions
     switch ($e->getName() or $e->getId()) {
         case 'Gray Dye':
             $e->getPlayer()->Sprint();
             break;
     }
 }
Ejemplo n.º 21
-1
 public function PlayerItemHeld(PlayerItemHeldEvent $event)
 {
     //分析手上拿的东西
     $player = $event->getPlayer();
     $itemid = $event->getItem()->getID();
     if ($itemid == 288) {
         $player->sendMessage($this->getLight($player->getLevel(), $player->getLocation()));
     }
 }
Ejemplo n.º 22
-1
 public function onHold(PlayerItemHeldEvent $event)
 {
     $p = $event->getPlayer();
     $item = $event->getItem();
     $this->resetEffects($p);
     if ($item->hasCompoundTag()) {
         $nbt = $item->getNamedTag();
         if (isset($nbt->AdvancedItemEffects)) {
             $enchant = $nbt->AdvancedItemEffects;
             $this->giveEffect($enchant, $p);
         }
         if ($item->getEnchantments() !== []) {
             foreach ($item->getEnchantments() as $e) {
                 if (($enchant = $this->data->get($e->getId() . " " . $e->getLevel())) !== null) {
                     $this->giveEffect($enchant, $p);
                 }
             }
         }
     }
 }
 public function onHoldItem(PlayerItemHeldEvent $event)
 {
     $session = $this->main->getSession($event->getPlayer());
     if (!$session instanceof Session) {
         $event->setCancelled();
         return;
     }
     if ($session->onHoldItem($event) === false) {
         $event->setCancelled();
     }
 }
Ejemplo n.º 24
-1
 public function onPlayerItemHeld(PlayerItemHeldEvent $event)
 {
     if ($event->getItem()->hasCompoundTag() && isset($event->getItem()->getNamedTag()->desc)) {
         $event->getPlayer()->sendPopup($event->getItem()->getNamedTag()["Desc"], $event->getItem()->getCustomName());
     }
     if ($this->isValidPlayer($event->getPlayer())) {
         $player = $this->players[$event->getPlayer()->getName()];
         $skill = $player->getSkillByItem($event->getItem());
         /**
          * @var $skill Skill
          */
         if ($skill !== null) {
             $event->getPlayer()->sendPopup(TextFormat::AQUA . self::getTranslation("LV") . "." . $skill->getLevel() . " " . self::getTranslation($skill->getName()));
         }
     }
 }
Ejemplo n.º 25
-1
 public function onItemHeld(PlayerItemHeldEvent $event)
 {
     $player = $event->getPlayer();
     $item = $event->getItem();
     if (isset($this->loadedGuns[$item->getId() . ":" . $item->getDamage()])) {
         $teamColor = [self::TEAM_BLUE => [40, 45, 208], self::TEAM_RED => [247, 2, 9], -1 => [175, 175, 175]];
         if (isset($this->gunCache[$player->getName()][$item->getId() . ":" . $item->getDamage()])) {
             $this->players[$player->getName()][0] = $this->gunCache[$player->getName()][$item->getId() . ":" . $item->getDamage()];
         } else {
             $this->players[$player->getName()][0] = new $this->loadedGuns[$item->getId() . ":" . $item->getDamage()]($this, $player, $teamColor[$this->players[$player->getName()][2]]);
             $this->gunCache[$player->getName()][$item->getId() . ":" . $item->getDamage()] = $this->players[$player->getName()][0];
         }
     }
 }
Ejemplo n.º 26
-1
 public function onItemHeld(PlayerItemHeldEvent $ev)
 {
     if ($ev->getPlayer()->getInventory()->getItemInHand()->getId() === 280) {
         $ev->getPlayer()->sendTip("§bStick§cPower §aEnabled!");
     }
 }
Ejemplo n.º 27
-1
 public function onItemHeld(PlayerItemHeldEvent $e)
 {
     if ($e->isCancelled()) {
         return;
     }
     $p = $e->getPlayer();
     $n = $p->getName();
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     if ($e->getItem()->getID() == Item::BOW) {
         return;
     }
     //echo __METHOD__.",".__LINE__."\n";//##DEBUG
     if (isset($this->shooters[$n])) {
         unset($this->shooters[$n]);
         $p->sendMessage("Disarming RPG");
     }
     if (isset($this->dumdums[$n])) {
         unset($this->dumdums[$n]);
         $p->sendMessage("Unloading dumdums");
     }
 }
Ejemplo n.º 28
-1
 public function onItem(PlayerItemHeldEvent $event)
 {
     $player = $event->getPlayer();
     $cfg = $this->getConfig();
     $holding = $cfg->get("sneak-on-item");
     $noholding = $cfg->get("sneak-off-item");
     $sneakonmsg = $cfg->get("sneak-on-popup");
     $sneakoffmsg = $cfg->get("sneak-off-popup");
     $sounds = $cfg->get("sounds");
     if ($player->hasPermission("isneak.use")) {
         $item = $event->getItem();
         if ($item instanceof Item) {
             $id = $item->getId();
             $damage = $item->getDamage();
         }
         if ($holding === $id) {
             if ($player instanceof Player) {
                 $this->enableSneak($player);
                 $player->sendPopup($sneakonmsg);
             }
             if ($sounds == "on") {
                 $sneakonsound = $cfg->get("sneak-on-sound");
                 $sneakoffsound = $cfg->get("sneak-off-sound");
                 $batsound = new BatSound($player);
                 $clicksound = new ClickSound($player);
                 $doorsound = new DoorSound($player);
                 $fizzsound = new FizzSound($player);
                 $launchsound = new LaunchSound($player);
                 $popsound = new PopSound($player);
                 //SneakOnSounds
                 if ($sneakonsound == "bat") {
                     $player->getLevel()->addSound($batsound);
                 } elseif ($sneakonsound == "click") {
                     $player->getLevel()->addSound($clicksound);
                 } elseif ($sneakonsound == "door") {
                     $player->getLevel()->addSound($doorsound);
                 } elseif ($sneakonsound == "fizz") {
                     $player->getLevel()->addSound($fizzsound);
                 } elseif ($sneakonsound == "launch") {
                     $player->getLevel()->addSound($launchsound);
                 } elseif ($sneakonsound == "pop") {
                     $player->getLevel()->addSound($popsound);
                 }
             } else {
                 //
             }
         }
         if ($noholding === $id) {
             if ($player instanceof Player) {
                 $this->disableSneak($player);
                 $player->sendPopup($sneakoffmsg);
             }
             if ($sounds == "on") {
                 $sneakonsound = $cfg->get("sneak-on-sound");
                 $sneakoffsound = $cfg->get("sneak-off-sound");
                 $batsound = new BatSound($player);
                 $clicksound = new ClickSound($player);
                 $doorsound = new DoorSound($player);
                 $fizzsound = new FizzSound($player);
                 $launchsound = new LaunchSound($player);
                 $popsound = new PopSound($player);
                 //SneakOffSounds
                 if ($sneakoffsound == "bat") {
                     $player->getLevel()->addSound($batsound);
                 } elseif ($sneakoffsound == "click") {
                     $player->getLevel()->addSound($clicksound);
                 } elseif ($sneakoffsound == "door") {
                     $player->getLevel()->addSound($doorsound);
                 } elseif ($sneakoffsound == "fizz") {
                     $player->getLevel()->addSound($fizzsound);
                 } elseif ($sneakoffsound == "launch") {
                     $player->getLevel()->addSound($launchsound);
                 } elseif ($sneakoffsound == "pop") {
                     $player->getLevel()->addSound($popsound);
                 }
             } else {
                 //
             }
         }
     }
 }
Ejemplo n.º 29
-1
 public function setHeldItemSlot($slot)
 {
     if ($slot >= -1 and $slot < $this->getSize()) {
         $item = $this->getItem($slot);
         $itemIndex = $this->getHeldItemIndex();
         for ($i = 0; $i < $this->getHotbarSize(); ++$i) {
             if ($this->getHotbarSlotIndex($i) === $slot) {
                 $itemIndex = $i;
                 break;
             }
         }
         if ($this->getHolder() instanceof Player) {
             Server::getInstance()->getPluginManager()->callEvent($ev = new PlayerItemHeldEvent($this->getHolder(), $item, $slot, $itemIndex));
             if ($ev->isCancelled()) {
                 $this->sendHeldItem($this->getHolder());
                 return;
             }
         }
         $this->setHotbarSlotIndex($itemIndex, $slot);
         $this->setHeldItemIndex($itemIndex);
     }
 }
Ejemplo n.º 30
-1
 public function onSelect(PlayerItemHeldEvent $event)
 {
     if ($event->getItem()->getId() === Item::BRICK) {
         $event->getPlayer()->sendPopup(TextFormat::RED . ($this->getConfig()->get("translation") !== false ? $this->getConfig()->get("translation") : "Firecracker"));
     }
 }