From 45146aa75bfc3397b8ca87ca872efa6a9cf732a8 Mon Sep 17 00:00:00 2001 From: Aaron Brock Date: Sun, 5 Jul 2015 19:48:35 -0400 Subject: [PATCH] Stuff Signed-off-by: Aaron Brock --- .../components/countdown/LobbyCountdown.php | 103 ++++++++++++++++++ .../game/components/world/WorldComponent.php | 4 +- 2 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/LobbyCountdown.php diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/LobbyCountdown.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/LobbyCountdown.php new file mode 100644 index 000000000..2c61747cd --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/LobbyCountdown.php @@ -0,0 +1,103 @@ +arena = $arena; + $this->gameStateComponent = $gameStateComponent; + + $this->startCount = $count; + $this->count = $count; + + $this->startGameState = $startGameState; + $this->setGameState = $setGameState; + + Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin()); + } + + + + function checkCountdown() + { + + } + + + + public function onGameStateChange(GameStateChangeEvent $event) + { + if ($event->getArena() !== $this->arena) + return; + + if ($event->getToGameState() == $this->startGameState) + { + BenchSchedule::runTaskTimer($this, 1000, 1000); + } + else + { + BenchSchedule::cancelTask($this); + $this->count = $this->startCount; + } + } + + + public function onEnd(ArenaEndEvent $event) + { + if ($event->getArena() !== $this->arena) + return; + HandlerList::unregisterAll($this); + } + + public function run(BenchTaskData $data) + { + print "Count: $this->count"."\n"; + + if ($this->count <= 0) + { + $this->gameStateComponent->setGameState($this->setGameState); + $data->end(); + } + + $this->popup(); + + $this->count--; + + + } + + public function popup() + { + foreach ($this->arena->getPlayers() as $player) + { + $player->sendPopup("Countdown: $this->count"); + } + } + +} \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/world/WorldComponent.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/world/WorldComponent.php index 6609349f0..8f6a4f65a 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/world/WorldComponent.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/world/WorldComponent.php @@ -52,7 +52,7 @@ class WorldComponent implements Listener $this->loadWorld("Super Smash Mobs"); } - //This is just some wierd testiong. Ignore it :P +// This is just some wierd testiong. Ignore it :P // public function onJoin(PlayerJoinEvent $event) // { // $this->player = $event->getPlayer(); @@ -128,6 +128,8 @@ class WorldComponent implements Listener print("Error Loading World: " . $this->gameFolder . "\n"); Server::getInstance()->getPluginManager()->callEvent(new WorldLoadFailEvent($this->arena)); + + $this->arena->endGame(); } }