diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/arenas/SingleGameArena.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/arenas/SingleGameArena.php index f6c7fcf2e..294f0a97d 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/arenas/SingleGameArena.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/arenas/SingleGameArena.php @@ -18,6 +18,7 @@ use mineplex\plugin\bench\game\Game; use mineplex\plugin\bench\arenas\events\ArenaCanJoinEvent; use mineplex\plugin\bench\arenas\events\ArenaJoinEvent; use mineplex\plugin\bench\arenas\events\ArenaQuitEvent; +use mineplex\plugin\bench\arenas\events\ArenaStartEvent; class SingleGameArena implements Arena, Listener { //I really have no idea if there is a better way to store players... but this is what I'm using for now. @@ -35,6 +36,7 @@ class SingleGameArena implements Arena, Listener { $this->game = $game; $this->plugin = $plugin; $this->getCurrentGame()->start($this); + Server::getInstance()->getPluginManager()->callEvent(new ArenaStartEvent($this)); } public function canJoin(Player $player) diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/arenas/events/ArenaStartEvent.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/arenas/events/ArenaStartEvent.php new file mode 100644 index 000000000..2fd03a23b --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/arenas/events/ArenaStartEvent.php @@ -0,0 +1,20 @@ +getPlugin()); + $this->gameStateComponent = $gameStateComponent; + + $this->startCount = $count; + $this->count = $count; + + $this + } + + public function onGameStateChange(GameStateChangeEvent $event) + { + if ($event->getArena() !== $this->arena) + return; + + + } + + + public function onRun($currentTick) + { + $this->plugin->getServer()->getPluginManager()->callEvent(new TickEvent($currentTick)); + } +} \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/game/components/gamestate/GameState.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/game/components/gamestate/GameState.php new file mode 100644 index 000000000..d72fbcbc8 --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/game/components/gamestate/GameState.php @@ -0,0 +1,21 @@ +arena = $arena; + $this->gameState = GameState::RESTARTING; + Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin()); + } + + public function onStart(ArenaStartEvent $event) + { + if ($event->getArena() !== $this->arena) + return; + $this->setGameState(GameState::LOBBY); + } + + public function onEnd(ArenaEndEvent $event) + { + if ($event->getArena() !== $this->arena) + return; + HandlerList::unregisterAll($this); + $this->setGameState(GameState::RESTARTING); + } + + + public function setGameState($gameState) + { + + if ($gameState < GameState::LOBBY) + $gameState = GameState::LOBBY; + + if ($gameState > GameState::RESTARTING) + $gameState = GameState::RESTARTING; + + if ($gameState == $this->gameState) + return false; + + if ($gameState == GameState::RESTARTING) + { + $this->arena->endGame(); + return true; + } + + $event = new GameStateChangeEvent($this->arena, $this->gameState, $gameState); + + //Not sure if I should call the event before of after... + Server::getInstance()->getPluginManager()->callEvent($event); + $this->gameState = $gameState; + + return true; + } + + public function getGameState() + { + return $this->gameState; + } + +} + +//$john = new GameStateComponent(); +//echo $john->getGameState(); diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/game/components/gamestate/Test.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/game/components/gamestate/Test.php new file mode 100644 index 000000000..eb777d4a3 --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/game/components/gamestate/Test.php @@ -0,0 +1,15 @@ +getGameState(); \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/game/components/gamestate/events/GameStateChangeEvent.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/game/components/gamestate/events/GameStateChangeEvent.php new file mode 100644 index 000000000..02e9be208 --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/bench/game/components/gamestate/events/GameStateChangeEvent.php @@ -0,0 +1,36 @@ +fromGameState = $fromGameState; + $this->toGameState = $toGameState; + } + + public function getFromGameState() + { + return $this->fromGameState; + } + + public function getToGameState() + { + return $this->toGameState; + } + +} \ No newline at end of file