2016-07-31 10:25:30 +00:00
|
|
|
<?php
|
|
|
|
use Ad5001\GameManager\Game;
|
|
|
|
use pocketmine\Player;
|
|
|
|
|
|
|
|
class Example extends Game {
|
|
|
|
|
|
|
|
public function onGameStart() {
|
2016-07-31 19:46:09 +00:00
|
|
|
$this->getLogger()->info("Game started");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function onGameStop() {
|
|
|
|
$this->getLogger()->info("Game stoped");
|
2016-08-05 12:31:34 +00:00
|
|
|
foreach($this->getLevel()->getPlayers() as $p) {
|
|
|
|
$p->setGamemode(0);
|
|
|
|
$p->teleport($this->getServer()->getDefaultLevel()->getSafeSpawn());
|
|
|
|
}
|
2016-07-31 19:46:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-02 07:25:31 +00: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 10:29:14 +00:00
|
|
|
|
2016-08-05 12:31:34 +00:00
|
|
|
public function onPlayerDeath(\pocketmine\event\PlayerDeathEvent $event) {
|
|
|
|
if(($this->getPlugin()->getInGamePlayers($this->getLevel()) - 1) == 0) {
|
|
|
|
$this->stop();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-01 10:29:14 +00:00
|
|
|
|
2016-07-31 19:46:09 +00:00
|
|
|
public function getName() : string {
|
|
|
|
return "Example";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getMinPlayers() : int {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function getMaxPlayers() : int {
|
|
|
|
return 5;
|
2016-07-31 10:25:30 +00:00
|
|
|
}
|
|
|
|
}
|