Esempio n. 1
0
 public function __construct(LegionPE $main)
 {
     parent::__construct($main);
     $this->main = $main;
     $this->spleefChan = $this->getMain()->getChannelManager()->joinChannel($main, "spleef", Channel::CLASS_MODULAR);
     $this->getMain()->getServer()->getPluginManager()->registerEvents($this, $main);
     $this->getMain()->getServer()->getScheduler()->scheduleDelayedRepeatingTask($this, 1, 1);
     for ($id = 1; $id <= Settings::spleef_arenaCnt(); $id++) {
         $this->arenas[$id] = new SpleefArena($this, $id);
         $this->arenas[$id]->reset();
     }
     $this->spleefWorld = $this->getMain()->getServer()->getLevelByName("world_spleef");
     $this->getMain()->getServer()->getScheduler()->scheduleRepeatingTask(new CallbackPluginTask($this->getMain(), function () {
         for ($id = 1; $id <= Settings::spleef_arenaCnt(); $id++) {
             Settings::spleef_updateArenaSigns($this->arenas[$id]);
         }
     }), 40);
 }
Esempio n. 2
0
 public function kick(SpleefSessionData $data, $reason, $checkPlayers = true)
 {
     if ($data->isSpectating()) {
         unset($this->specs[$data->getSession()->getUID()]);
     } elseif ($checkPlayers) {
         unset($this->players[$data->getSession()->getUID()]);
         if (count($this->players) === 1) {
             /** @var SpleefSessionData $winner */
             $winner = array_values($this->players)[0];
             $award = 16 * Settings::coinsFactor($winner->getSession());
             $this->broadcast("The match has ended. {$winner->getSession()} won the match and is awarded with {$award} coins.");
             $winner->getSession()->setCoins($coins = $winner->getSession()->getCoins() + $award);
             $winner->getSession()->tell("You now have {$coins} coins.");
             $winner->addWin();
             $this->game->getDefaultChatChannel()->broadcast("{$winner} won a match in {$this}!");
             $this->reset();
         }
         Settings::spleef_updateArenaSigns($this);
     }
     $data->quitArena();
     $data->getSession()->tell("You left {$this->config->name}: {$reason}.");
     $data->getSession()->teleport(Settings::spleef_spawn($this->game->getMain()->getServer()));
 }