diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/GameStateCountdown.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/GameStateCountdown.php index 7cb84f920..4c51f99f8 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/GameStateCountdown.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/countdown/GameStateCountdown.php @@ -11,13 +11,15 @@ namespace mineplex\plugin\gameengine\game\components\countdown; use mineplex\plugin\gameengine\arenas\Arena; use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent; use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent; +use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent; use mineplex\plugin\gameengine\time\BenchSchedule; use mineplex\plugin\gameengine\time\BenchTask; use mineplex\plugin\gameengine\time\BenchTaskData; + use pocketmine\event\HandlerList; use pocketmine\event\Listener; use pocketmine\Server; -use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent; + class GameStateCountdown implements Listener, BenchTask { @@ -69,17 +71,17 @@ class GameStateCountdown implements Listener, BenchTask { public function run(BenchTaskData $data) { - print "§$this->startGameState---"."\n"; - + //print "§$this->startGameState---"."\n"; + $this->popup(); if ($this->count <= 0) { $this->gameStateComponent->setGameState($this->setGameState); $data->end(); } - - $this->popup(); - - $this->count--; + else + { + $this->count--; + } } diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/FreezePlayers.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/FreezePlayers.php new file mode 100644 index 000000000..d27893472 --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/FreezePlayers.php @@ -0,0 +1,87 @@ +spectateComponent = $spectateComponent; + } + + function onMove(PlayerMoveEvent $event) + { + + if (!$this->hasPlayer($event->getPlayer())) + return; + + if ($event->getFrom()->getFloorX() != $event->getTo()->getFloorX() || $event->getFrom()->getFloorZ() != $event->getTo()->getFloorZ()) + $event->setCancelled(); + } + + public function enable() + { + parent::enable(); + + $effect = new Effect(Effect::SLOWNESS, "Waiting till game start...", 0, 0, 0, true); + $effect->setVisible(false)->setAmplifier(9)->setDuration(PHP_INT_MAX); + print "Player Count: " . count($this->getPlayers()) . "\n"; + foreach ($this->getPlayers() as $player) + { + print "Adding effect! \n"; + $player->addEffect($effect); + } + } + + public function disable() + { + parent::disable(); + print "Player Count: " . count($this->getPlayers()) . "\n"; + foreach ($this->getPlayers() as $player) + { + print "Adding effect! \n"; + $player->removeEffect(Effect::SLOWNESS); + } + } + + + /** + * @return Player[] + */ + private function getPlayers() + { + if ($this->spectateComponent !== null) + return $this->spectateComponent->getNonSpectators(); + else + return $this->getArena()->getPlayers(); + } + + /** + * @param Player $player + * @return bool + */ + private function hasPlayer(Player $player) + { + if ($this->spectateComponent !== null) + return $this->spectateComponent->isNotSpectating($player); + else + return $this->getArena()->hasPlayer($player); + } +} \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/NoDamage.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/NoDamage.php index b47145899..d43b2cefa 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/NoDamage.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/NoDamage.php @@ -25,7 +25,7 @@ class NoDamage extends ListenerFeature { { if (!$this->getArena()->hasPlayer($event->getEntity())) return; - Server::getInstance()->broadcastMessage("Stopped!"); + //Server::getInstance()->broadcastMessage("Stopped!"); $event->setCancelled(); } } \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/games/sg/SurvivalGames.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/games/sg/SurvivalGames.php index c5b86fca4..b1bdbd1a6 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/games/sg/SurvivalGames.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/games/sg/SurvivalGames.php @@ -11,6 +11,7 @@ namespace mineplex\plugin\gameengine\game\games\sg; use mineplex\plugin\gameengine\arenas\Arena; use mineplex\plugin\gameengine\game\components\countdown\GameStateCountdown; use mineplex\plugin\gameengine\game\components\feature\features\DeathSpectate; +use mineplex\plugin\gameengine\game\components\feature\features\FreezePlayers; use mineplex\plugin\gameengine\game\components\feature\features\JoinSpectate; use mineplex\plugin\gameengine\game\components\feature\features\NoBlockBreak; use mineplex\plugin\gameengine\game\components\feature\features\NoBlockPlace; @@ -21,7 +22,10 @@ use mineplex\plugin\gameengine\game\components\feature\managers\GameStateFeature use mineplex\plugin\gameengine\game\components\gamestate\GameState; use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent; use mineplex\plugin\gameengine\game\components\lobby\LobbyComponent; +use mineplex\plugin\gameengine\game\components\spawn\SimpleSpawnComponent; +use mineplex\plugin\gameengine\game\components\spawn\SpawnAt; use mineplex\plugin\gameengine\game\components\spectate\GameModeSpectateComponent; +use mineplex\plugin\gameengine\game\components\world\WorldComponent; use mineplex\plugin\gameengine\game\Game; use mineplex\plugin\gameengine\game\components\countdown\LobbyCountdown; use mineplex\plugin\gameengine\game\components\feature\Feature; @@ -34,7 +38,11 @@ class SurvivalGames implements Game { $spectateComponent = new GameModeSpectateComponent($arena); - //Init features + $worldComponent = new WorldComponent($arena); + + new LobbyComponent($arena); + + //Features start---- $noDamage = new NoDamage($arena); $joinSpectate = new JoinSpectate($arena, $spectateComponent); @@ -43,10 +51,7 @@ class SurvivalGames implements Game { /** @var Feature[][] $features */ $features = array( - //Just here cause I'm not using LobbyComponent atm - //GameState::LOBBY => array( $stopEveryThing, $noDamage, ), - - GameState::PRE_GAME => array( $stopEveryThing, $noDamage, $joinSpectate), + GameState::PRE_GAME => array( $stopEveryThing, $noDamage, $joinSpectate, new FreezePlayers($arena, $spectateComponent)), GameState::GAME => array( $stopEveryThing, $joinSpectate , new DeathSpectate($arena, $spectateComponent)), @@ -54,15 +59,18 @@ class SurvivalGames implements Game { ); - new LobbyComponent($arena); - new GameStateFeatureManager($arena, $features); + //Features end--- - new LobbyCountdown( $arena, $gameStateComponent, null, GameState::LOBBY, GameState::PRE_GAME, 10, 2); + + + new SpawnAt($arena, new SimpleSpawnComponent($arena, $worldComponent), [GameState::PRE_GAME]); + + new LobbyCountdown( $arena, $gameStateComponent, $worldComponent, GameState::LOBBY, GameState::PRE_GAME, 10, 2); //new GameStateCountdown($arena, $gameStateComponent, 5, GameState::LOBBY, GameState::PRE_GAME); - new GameStateCountdown($arena, $gameStateComponent, 5, GameState::PRE_GAME, GameState::GAME); + new GameStateCountdown($arena, $gameStateComponent, 20, GameState::PRE_GAME, GameState::GAME); //new GameStateCountdown($arena, $gameStateComponent, 5, GameState::GAME, GameState::POST_GAME); new LMSVictoryType( $arena, $spectateComponent, $gameStateComponent); diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilTeleport.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilTeleport.php index b322c7929..bc414ac2e 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilTeleport.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilTeleport.php @@ -20,65 +20,28 @@ use pocketmine\network\protocol\UpdateBlockPacket; class UtilTeleport { - public static function teleport(Player $player, Position $pos) - { + public static function teleport(Player $player, Position $position) { - $player->noDamageTicks = 20; + $current = $player->getPosition(); - //$player->teleport($pos); + // + // This CRAZY HACK is to remove Tile entities that seem to linger + // whenever you teleport! + // - $current = $player->getLevel(); - - if ($current->getName() != $pos->getLevel()) { - - foreach ($pos->getLevel()->getTiles() as $tile) - { + if ($current->getLevel() != $position->getLevel()) { + $player->noDamageTicks = 20; + foreach ($current->getLevel()->getTiles() as $tile) { $pk = new UpdateBlockPacket(); - - - $pk->x = $tile->x; $pk->y = $tile->y; $pk->z = $tile->z; - - - $pk->block = $tile->getBlock(); - $pk->meta = $tile->metadata; - - Packet - + $pk->block = 0; + $pk->meta = 0; $player->dataPacket($pk); } - - /* - foreach ($current->getTiles() as $tile) { - - $pk = new UpdateBlockPacket(); - - $thereTile = $pos->getLevel()->getTile(new Vector3($tile->x, $tile->y, $tile->z)); - - $pk->x = $tile->x; - $pk->y = $tile->y; - $pk->z = $tile->z; - if ($thereTile !== null) - { - print "There tile is not null!"; - $pk->block = $thereTile->getBlock(); - $pk->meta = $thereTile->metadata; - } - else - { - print "null!"; - $pk->block = 0; - $pk->meta = 0; - } - - - $player->dataPacket($pk); - } - */ } - //$player->sendChunk() - $player->teleport($pos); + $player->teleport($position); // Start the teleport + return true; } } \ No newline at end of file