diff --git a/src/Ad5001/UHC/Main.php b/src/Ad5001/UHC/Main.php index 5bb48f7..d1d9e02 100644 --- a/src/Ad5001/UHC/Main.php +++ b/src/Ad5001/UHC/Main.php @@ -81,6 +81,8 @@ class Main extends PluginBase implements Listener{ $this->saveDefaultConfig(); mkdir($this->getDataFolder() . "scenarios"); $this->getServer()->getPluginManager()->registerEvents($this, $this); + $this->getServer()->getPluginManager()->registerEvent("\Ad5001\UHC\event\GameStartEvent", $this, \pocketmine\plugin\EventPriority::NORMAL, new \pocketmine\plugin\MethodEventExecutor("onGameStart"), $this, true); + $this->getServer()->getPluginManager()->registerEvent("\Ad5001\UHC\event\GameStopEvent", $this, \pocketmine\plugin\EventPriority::NORMAL, new \pocketmine\plugin\MethodEventExecutor("onGameStop"), $this, true); $this->UHCManager = new UHCManager($this); $this->games = []; $this->quit = []; diff --git a/src/Ad5001/UHC/UHCGame.php b/src/Ad5001/UHC/UHCGame.php index 95cfcf8..791a834 100644 --- a/src/Ad5001/UHC/UHCGame.php +++ b/src/Ad5001/UHC/UHCGame.php @@ -36,7 +36,7 @@ class UHCGame implements Listener{ public function __construct(Plugin $plugin, UHCWorld $world) { $this->m = $plugin; $this->world = $world; - $plugin->getServer()->registerEvets($this, $plugin); + $plugin->getServer()->getPluginManager()->registerEvents($this, $plugin); $this->players = $world->getLevel()->getPlayers(); $event = new GameStartEvent($this, $world, $this->players); $this->m->getServer()->getPluginManager()->callEvent($event); diff --git a/src/Ad5001/UHC/event/GameFinishEvent.php b/src/Ad5001/UHC/event/GameStopEvent.php similarity index 91% rename from src/Ad5001/UHC/event/GameFinishEvent.php rename to src/Ad5001/UHC/event/GameStopEvent.php index b280f2b..63343ca 100644 --- a/src/Ad5001/UHC/event/GameFinishEvent.php +++ b/src/Ad5001/UHC/event/GameStopEvent.php @@ -15,21 +15,34 @@ use Ad5001\UHC\UHCWorld; protected $game; protected $world; protected $winner; -class GameFinishEvent extends UHCEvent implements Cancellable { + + +class GameStopEvent extends UHCEvent implements Cancellable { + + + public function __construct($game, $world, $winner) { $this->game = $game; $this->world = $world; $this->winner = $winner; } + + public function getWorld() { return $this->world; } + + public function getLevel() { return $this->world; } + + public function getWinner() { return $this->winner; } + + public function setWinner(Player $winner) { $this->winner = $winner; } diff --git a/src/Ad5001/UHC/event/UHCEvent.php b/src/Ad5001/UHC/event/UHCEvent.php index 01a4ff8..87ea41a 100644 --- a/src/Ad5001/UHC/event/UHCEvent.php +++ b/src/Ad5001/UHC/event/UHCEvent.php @@ -9,7 +9,11 @@ namespace Ad5001\UHC\event; use pocketmine\event\Event; abstract class UHCEvent extends Event { + + public function getGame() { return $this->game; } + + } \ No newline at end of file