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; } }