Exemplo n.º 1
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;
     }
 }
Exemplo n.º 2
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();
     }
 }
 /**
  * @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"));
     }
 }
Exemplo n.º 4
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;
     }
 }
 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();
     }
 }