2016-07-31 13:25:30 +03:00
|
|
|
<?php
|
|
|
|
use Ad5001\GameManager\Game;
|
|
|
|
use pocketmine\Player;
|
|
|
|
|
|
|
|
class Example extends Game {
|
|
|
|
|
|
|
|
public function onGameStart() {
|
2016-07-31 22:46:09 +03:00
|
|
|
$this->getLogger()->info("Game started");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function onGameStop() {
|
|
|
|
$this->getLogger()->info("Game stoped");
|
2016-08-05 15:31:34 +03:00
|
|
|
foreach($this->getLevel()->getPlayers() as $p) {
|
|
|
|
$p->setGamemode(0);
|
|
|
|
$p->teleport($this->getServer()->getDefaultLevel()->getSafeSpawn());
|
|
|
|
}
|
2016-07-31 22:46:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-02 10:25:31 +03:00
|
|
|
public function onJoin(Player $player) {
|
|
|
|
parent::onJoin($player);
|
|
|
|
$this->getPlugin()->getLogger()->info($player->getName() . " joined the game " . $this->getName() . " in world " . $this->getLevel()->getName());
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function onQuit(Player $player) {
|
|
|
|
parent::onJoin($player);
|
|
|
|
$this->getPlugin()->getLogger()->info($player->getName() . " left the game " . $this->getName() . " in world " . $this->getLevel()->getName());
|
|
|
|
}
|
|
|
|
|
2016-08-01 13:29:14 +03:00
|
|
|
|
2016-08-05 18:18:24 +03:00
|
|
|
public function onPlayerDeath(\pocketmine\event\player\PlayerDeathEvent $event) {
|
|
|
|
$event->getPlayer()->setGamemode(3);
|
2016-08-05 15:31:34 +03:00
|
|
|
if(($this->getPlugin()->getInGamePlayers($this->getLevel()) - 1) == 0) {
|
|
|
|
$this->stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-01 13:29:14 +03:00
|
|
|
|
2016-07-31 22:46:09 +03:00
|
|
|
public function getName() : string {
|
|
|
|
return "Example";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getMinPlayers() : int {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getMaxPlayers() : int {
|
|
|
|
return 5;
|
2016-07-31 13:25:30 +03:00
|
|
|
}
|
|
|
|
}
|