Example #1
0
 public function switchSession($id)
 {
     if ($this->getInventorySession() !== self::INV_NORMAL_ACCESS) {
         $this->setInventorySession(self::INV_NORMAL_ACCESS);
     }
     if ($this->session === $id) {
         return false;
     }
     $game = $this->main->getGame($this->session);
     if ($game instanceof Game) {
         if (!$game->onQuit($this, false)) {
             return false;
         }
         $chan = $game->getDefaultChatChannel();
         $this->unsubscribeFromChannel($chan);
     }
     if ($this->writeToChannel->getClass() === Channel::CLASS_MODULAR) {
         $this->writeToChannel->unsubscribe($this);
     }
     $this->session = $id;
     $game = $this->main->getGame($id);
     if ($game instanceof Game) {
         $this->writeToChannel = $this->main->getChannelManager()->joinChannel($this, $game->getDefaultChatChannel(), Channel::CLASS_MODULAR);
     } else {
         $this->writeToChannel = $this->main->getDefaultChannel();
         $this->writeToChannel->subscribe($this);
         $this->onHub();
     }
     return true;
 }
Example #2
0
 public function __construct(LegionPE $main, $tid, $name, $maxCapacity, $isOpen = true, $members = [], $invited = "", $requires = "", $rules = "")
 {
     $this->main = $main;
     $this->tid = $tid;
     $this->name = $name;
     $this->maxCapacity = $maxCapacity;
     $this->open = $isOpen;
     $this->members = $members;
     $this->invited = $invited === "" ? [] : array_fill_keys(array_map("intval", explode(",", $invited)), true);
     $this->requires = $requires;
     $this->rules = $rules;
     $this->chan = $main->getChannelManager()->joinChannel($this, "team_{$this}", Channel::CLASS_TEAM);
 }