From d6fd7f4dd92adc5145c0e9062e965080595c8976 Mon Sep 17 00:00:00 2001 From: Aaron Brock Date: Thu, 9 Jul 2015 01:30:28 -0400 Subject: [PATCH] sutff Signed-off-by: Aaron Brock --- Pocket/plugins/Mineplex/src/Test.php | 9 +- .../Mineplex/src/mineplex/plugin/Main.php | 4 +- .../plugin/gameengine/arenas/Arena.php | 6 + .../gameengine/arenas/MultiGameArena.php | 9 + .../countdown/GameStateCountdown.php | 2 +- .../components/countdown/LobbyCountdown.php | 22 +-- .../components/feature/ListenerFeature.php | 4 +- .../feature/features/JoinSpectate.php | 50 +++++ .../components/feature/features/NoDamage.php | 46 +++++ .../managers/GameStateFeatureManager.php | 39 +++- .../components/spawn/SimpleSpawnComponent.php | 5 +- .../components/victorytype/LMSVictoryType.php | 180 ++++++++++++++++++ .../game/components/world/WorldComponent.php | 1 + .../game/games/sg/SurvivalGames.php | 54 +++--- .../src/mineplex/plugin/util/UtilArray.php | 10 +- .../src/mineplex/plugin/util/UtilFile.php | 15 +- .../src/mineplex/plugin/util/UtilTeleport.php | 84 ++++++++ 17 files changed, 473 insertions(+), 67 deletions(-) create mode 100644 Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/JoinSpectate.php create mode 100644 Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/NoDamage.php create mode 100644 Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/victorytype/LMSVictoryType.php create mode 100644 Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilTeleport.php diff --git a/Pocket/plugins/Mineplex/src/Test.php b/Pocket/plugins/Mineplex/src/Test.php index 42337416e..658c1d884 100644 --- a/Pocket/plugins/Mineplex/src/Test.php +++ b/Pocket/plugins/Mineplex/src/Test.php @@ -7,9 +7,6 @@ */ -$a1 = array(); -$a2 = array($a1); - -array_push($a1, $a2); - -print_r($a1); \ No newline at end of file +$array = array(); +array_push($array, $array); +print_r($array); \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/Main.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/Main.php index 03cc4a21e..fb64e78ad 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/Main.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/Main.php @@ -15,6 +15,7 @@ use pocketmine\event\player\PlayerDeathEvent; use pocketmine\event\player\PlayerInteractEvent; use pocketmine\event\player\PlayerJoinEvent; use pocketmine\event\player\PlayerLoginEvent; +use pocketmine\event\player\PlayerRespawnEvent; use pocketmine\level\Position; use pocketmine\math\Vector3; use pocketmine\Player; @@ -40,9 +41,10 @@ class Main extends PluginBase implements Listener $this->arena->getPlugin()->getServer()->getLevelByName("world")->setSpawnLocation(new Vector3(0, 200, 0)); } + public function onLogin(PlayerLoginEvent $event) { - UtilFile::deleteDir('players/' . $event->getPlayer()->getName() . '.dat'); + //UtilFile::deleteDir('players/' . $event->getPlayer()->getName() . '.dat'); if ($this->arena->canJoin($event->getPlayer())) return; diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/arenas/Arena.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/arenas/Arena.php index 1c4fd18c1..bcebb99db 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/arenas/Arena.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/arenas/Arena.php @@ -31,6 +31,12 @@ interface Arena */ public function hasPlayer($player); + /** + * @param string $message + * @return void + */ + public function broadcast($message); + /** * @return Plugin */ diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/arenas/MultiGameArena.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/arenas/MultiGameArena.php index 5ae4372c3..2c8df6026 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/arenas/MultiGameArena.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/arenas/MultiGameArena.php @@ -72,6 +72,7 @@ class MultiGameArena implements Arena, Listener public function endGame() { + Server::getInstance()->broadcastMessage("Game Over!"); Server::getInstance()->getPluginManager()->callEvent(new ArenaEndEvent($this)); $this->startGame(); } @@ -99,6 +100,14 @@ class MultiGameArena implements Arena, Listener return in_array($player, $this->getPlayers()); } + public function broadcast($message) + { + foreach ($this->getPlayers() as $player) + { + $player->sendMessage($message); + } + } + public function getCurrentGame() { return $this->game; 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 0ee90f870..7cb84f920 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 @@ -69,7 +69,7 @@ class GameStateCountdown implements Listener, BenchTask { public function run(BenchTaskData $data) { - print "Count: $this->count"."\n"; + print "§$this->startGameState---"."\n"; if ($this->count <= 0) { 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 index 0ccf4200b..9afce41f5 100644 --- 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 @@ -12,22 +12,17 @@ use mineplex\plugin\gameengine\arenas\Arena; use mineplex\plugin\gameengine\arenas\events\ArenaEndEvent; use mineplex\plugin\gameengine\arenas\events\ArenaJoinEvent; use mineplex\plugin\gameengine\arenas\events\ArenaQuitEvent; +use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent; use mineplex\plugin\gameengine\game\components\gamestate\GameStateComponent; use mineplex\plugin\gameengine\game\components\world\event\WorldLoadSuccessEvent; use mineplex\plugin\gameengine\game\components\world\WorldComponent; use mineplex\plugin\gameengine\time\BenchSchedule; use mineplex\plugin\gameengine\time\BenchTask; use mineplex\plugin\gameengine\time\BenchTaskData; -use pocketmine\entity\Effect; use pocketmine\event\HandlerList; use pocketmine\event\Listener; -use pocketmine\event\player\PlayerDeathEvent; -use pocketmine\network\protocol\AnimatePacket; -use pocketmine\network\protocol\ContainerSetDataPacket; -use pocketmine\network\protocol\DropItemPacket; use pocketmine\Player; use pocketmine\Server; -use mineplex\plugin\gameengine\game\components\gamestate\events\GameStateChangeEvent; class LobbyCountdown implements Listener, BenchTask { @@ -42,13 +37,11 @@ class LobbyCountdown implements Listener, BenchTask { private $message; - const WAITING_FOR_PLAYERS = "Waiting for players!"; - const POPUP_ID = "popup"; const COUNTDOWN_ID = "count"; - public function __construct(Arena $arena, GameStateComponent $gameStateComponent, WorldComponent $worldComponent, $startGameState, $setGameState, $count, $minPlayers = 2) + public function __construct(Arena $arena, GameStateComponent $gameStateComponent, $worldComponent = null, $startGameState, $setGameState, $count, $minPlayers = 2) { $this->arena = $arena; $this->gameStateComponent = $gameStateComponent; @@ -61,9 +54,9 @@ class LobbyCountdown implements Listener, BenchTask { $this->startGameState = $startGameState; $this->setGameState = $setGameState; - $this->message = self::WAITING_FOR_PLAYERS; - Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin()); + + $this->checkCountdown(); } @@ -74,7 +67,7 @@ class LobbyCountdown implements Listener, BenchTask { { $playerCount = (count($this->arena->getPlayers()) + $addOne); - if ($this->gameStateComponent->getGameState() == $this->startGameState && $this->worldComponent->isWorldReady() && $playerCount >= $this->minPlayers) + if ($this->gameStateComponent->getGameState() == $this->startGameState && ($this->worldComponent == null || $this->worldComponent->isWorldReady()) && $playerCount >= $this->minPlayers) { if (!BenchSchedule::isRunningWithId($this, self::COUNTDOWN_ID)) { @@ -104,7 +97,8 @@ class LobbyCountdown implements Listener, BenchTask { { if ($event->getArena() !== $this->arena) return; - $this->checkCountdown(); + if ($this->gameStateComponent->getGameState() == $this->startGameState) + $this->checkCountdown(); } public function onWorldCreation(WorldLoadSuccessEvent $event) @@ -192,6 +186,6 @@ class LobbyCountdown implements Listener, BenchTask { private function popup(Player $player) { - $player->sendTip($this->message); + $player->sendPopup($this->message); } } \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/ListenerFeature.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/ListenerFeature.php index 6446a631f..e6e9a3896 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/ListenerFeature.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/ListenerFeature.php @@ -39,11 +39,11 @@ class ListenerFeature implements Feature, Listener { } /** - * @return boolean + * @return bool */ public function isEnabled() { - $this->enabled; + return $this->enabled; } /** diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/JoinSpectate.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/JoinSpectate.php new file mode 100644 index 000000000..07988a691 --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/JoinSpectate.php @@ -0,0 +1,50 @@ +spectateComponent = $spectateComponent; + $this->id = rand(0, 99999); + } + + function onJoin(ArenaJoinEvent $event) + { + if ($this->getArena() !== $event->getArena()) + return; + $this->spectateComponent->enableSpectate($event->getPlayer()); + } + public function enable() + { + Server::getInstance()->broadcastMessage("JoinSpectate enable! : $this->id"); + parent::enable(); + print "JoinSpectate enable? " . ($this->isEnabled() ? 'true' : 'false') . "\n"; + } + + public function disable() + { + Server::getInstance()->broadcastMessage("JoinSpectate disable!"); + parent::disable(); + } + +} \ 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 new file mode 100644 index 000000000..f8113ee0c --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/NoDamage.php @@ -0,0 +1,46 @@ +getArena()->hasPlayer($event->getEntity())) + return; + $event->setCancelled(); + } + + public function enable() + { + Server::getInstance()->broadcastMessage("Death enable!"); + parent::enable(); + } + + public function disable() + { + Server::getInstance()->broadcastMessage("Death disable!"); + parent::disable(); + } + + +} \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/managers/GameStateFeatureManager.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/managers/GameStateFeatureManager.php index 9d9cc03b9..dba569cd0 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/managers/GameStateFeatureManager.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/managers/GameStateFeatureManager.php @@ -40,7 +40,9 @@ class GameStateFeatureManager implements Listener { foreach ($features as $key => $value) { + $this->features[$key] = UtilArray::getValuesRecursively($value); + print "$key: " . count($this->features[$key]) . "\n"; } Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin()); @@ -66,20 +68,55 @@ class GameStateFeatureManager implements Listener { else $theseFeatures = []; + print "\nLast Count: ". count($lastFeatures); + print "\nThese Count: ". count($theseFeatures); + + /** @var Feature[] $toEnable */ $toEnable = UtilArray::arrayDiff($theseFeatures, $lastFeatures); + print "\nEnable Count: ". count($toEnable); + /** @var Feature[] $toDisable */ $toDisable = UtilArray::arrayDiff($lastFeatures, $theseFeatures); + print "\nDisable Count: ". count($toDisable); + + print "\n"; + + foreach ($toDisable as $feature) + { + if (in_array($feature, $theseFeatures)) + print "An error has happened!!\n"; + else + print "All good ^_^\n"; + } + foreach ($toDisable as $feature) { if ($feature->isEnabled()) + { + print "Disable: " . get_class($feature) . spl_object_hash($feature) . "\n"; $feature->disable(); + } + else + { + print get_class($feature) . "\n" . "Is already disabled!" . "\n"; + } } + foreach ($toEnable as $feature) { if (!$feature->isEnabled()) + { + print "Enable: " . get_class($feature) . spl_object_hash($feature) . "\n"; $feature->enable(); + } + else + { + print get_class($feature) . "\n" . "Is already enabled!" . "\n"; + } + } + } public function onEnd(ArenaEndEvent $event) @@ -87,7 +124,7 @@ class GameStateFeatureManager implements Listener { if ($event->getArena() !== $this->arena) return; - $iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator($this->features)); + $iterator = UtilArray::getValuesRecursively($this->features); foreach ($iterator as $feature) { if ($feature->isEnabled()) diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/spawn/SimpleSpawnComponent.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/spawn/SimpleSpawnComponent.php index d9ab860a0..30bd97943 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/spawn/SimpleSpawnComponent.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/spawn/SimpleSpawnComponent.php @@ -15,6 +15,7 @@ use mineplex\plugin\gameengine\game\components\world\event\WorldLoadSuccessEvent use mineplex\plugin\gameengine\game\components\world\WorldComponent; use mineplex\plugin\Main; use mineplex\plugin\util\UtilArray; +use mineplex\plugin\util\UtilTeleport; use pocketmine\event\HandlerList; use pocketmine\event\Listener; use pocketmine\level\Position; @@ -86,8 +87,8 @@ class SimpleSpawnComponent implements SpawnComponent, Listener { //$pos = $pos->getLevel()->getSpawnLocation(); print_r($pos); - - $player->teleport($pos); + UtilTeleport::teleport($player, $pos); + //$player->teleport($pos); $player->sendMessage("After:"); Main::sendLoc($player); diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/victorytype/LMSVictoryType.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/victorytype/LMSVictoryType.php new file mode 100644 index 000000000..51d50ed7c --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/victorytype/LMSVictoryType.php @@ -0,0 +1,180 @@ +arena = $arena; + $this->duringGame = new DuringGame($arena, $spectateComponent, $gameStateComponent, $endPlayersAmount); + + Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin()); + } + + + public function gameStateChange(GameStateChangeEvent $event) + { + if ($this->arena !== $event->getArena()) + return; + + if ($event->getToGameState() == GameState::GAME) + { + UtilFeature::enable($this->duringGame); + } + elseif ($event->getFromGameState() == GameState::GAME) + { + UtilFeature::disable($this->duringGame); + } + } + + public function onEnd(ArenaEndEvent $event) + { + if ($this->arena !== $event->getArena()) + return; + UtilFeature::disable($this->duringGame); + HandlerList::unregisterAll($this); + } + + +} + +class DuringGame extends ListenerFeature implements BenchTask { + + /** @var Player[] */ + private $rank = []; + + /** @var Arena */ + private $arena; + + /** @var SpectateComponent */ + private $spectateComponent; + + /** @var GameStateComponent */ + private $gameStateComponent; + + /** @var int */ + private $endPlayersAmount; + + function __construct(Arena $arena, SpectateComponent $spectateComponent, GameStateComponent $gameStateComponent, $endPlayersAmount = 1) + { + parent::__construct($arena); + $this->arena = $arena; + $this->spectateComponent = $spectateComponent; + $this->gameStateComponent = $gameStateComponent; + $this->endPlayersAmount = $endPlayersAmount; + } + + #On LOWEST so I can check if the player is spectating, as the player is removed from the spectating list on LOW + /** + * @priority LOWEST + * @param ArenaQuitEvent $event + */ + public function onLeave(ArenaQuitEvent $event) + { + if ($this->arena !== $event->getArena()) + return; + + if (!$this->spectateComponent->isSpectating($event->getPlayer())) + array_push($this->rank, $event->getPlayer()); + } + + + public function onSpectate(EnableSpectateEvent $event) + { + if ($this->arena !== $event->getArena()) + return; + + array_push($this->rank, $event->getPlayer()); + + $this->checkEndGame(true); + } + + public function checkEndGame($subtract = false) + { + if ($this->gameStateComponent->getGameState() != GameState::GAME) + { + if ($this->isEnabled()) + $this->disable(); + return; + } + + $count = count($this->spectateComponent->getNonSpectators()) - $subtract; + + if ($count <= $this->endPlayersAmount) + { + $this->gameStateComponent->setGameState(GameState::POST_GAME); + } + } + + private function sendWinners() + { + foreach ($this->spectateComponent->getNonSpectators() as $player) + { + array_push($this->rank, $player); + } + /** @var Player[] $rank */ + $rank = array_reverse($this->rank); + + $counter = 0; + $this->arena->broadcast("----------"); + $this->arena->broadcast(""); + + foreach ($rank as $player) + { + $counter++; + $this->arena->broadcast("$counter. §e" . $player->getName()); + if ($counter >= 3) + break; + } + + $this->arena->broadcast(""); + $this->arena->broadcast("----------"); + } + + public function run(BenchTaskData $task) + { + $this->checkEndGame(); + } + + public function enable() + { + BenchSchedule::runTaskLater($this, 0); + parent::enable(); + } + + public function disable() + { + $this->sendWinners(); + BenchSchedule::cancelTask($this); + parent::disable(); + } +} \ 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 093732b04..e6672eae1 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 @@ -18,6 +18,7 @@ use mineplex\plugin\util\UtilString; use mineplex\plugin\util\UtilFile; use pocketmine\event\HandlerList; use pocketmine\event\Listener; +use pocketmine\event\player\PlayerRespawnEvent; use pocketmine\level\Position; use pocketmine\math\Vector3; use pocketmine\Server; 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 77ed45aa2..fc4673846 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 @@ -8,68 +8,62 @@ 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\countdown\LobbyCountdown; use mineplex\plugin\gameengine\game\components\feature\features\DeathSpectate; +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; +use mineplex\plugin\gameengine\game\components\feature\features\NoDamage; use mineplex\plugin\gameengine\game\components\feature\features\NoDropItem; use mineplex\plugin\gameengine\game\components\feature\features\NoPickUpItem; use mineplex\plugin\gameengine\game\components\feature\managers\GameStateFeatureManager; 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\arenas\Arena; -use mineplex\plugin\gameengine\game\components\feature\Feature; -use mineplex\plugin\gameengine\time\BenchSchedule; -use mineplex\plugin\gameengine\time\BenchTask; -use mineplex\plugin\gameengine\time\BenchTaskData; -use pocketmine\item\Item; + class SurvivalGames implements Game { - /** @var Arena */ - private $arena; function start(Arena $arena) { - $this->arena = $arena; - $gameStateComponent = new GameStateComponent($arena); - //$spectateComponent = new GameModeSpectateComponent($arena); + $spectateComponent = new GameModeSpectateComponent($arena); //Init features - //$noPickUpItem = new NoPickUpItem($arena, [Item::GRASS], true); + $noDamage = new NoDamage($arena); + $joinSpectate = new JoinSpectate($arena, $spectateComponent); - //$pack = array(new NoBlockBreak($arena, [Item::GRASS]), new NoBlockPlace($arena, [Item::WOOD], true),new NoDropItem($arena, [Item::APPLE], true)); + $stopEveryThing = array(new NoBlockBreak($arena), new NoBlockPlace($arena),new NoDropItem($arena), new NoPickUpItem($arena)); /** @var Feature[][] $features */ - //$features = array( - // GameState::LOBBY => array($noPickUpItem, $pack) - //); + $features = array( - //new GameStateFeatureManager($arena, $features); + //Just here cause I'm not using LobbyComponent atm + GameState::LOBBY => array( $stopEveryThing, $noDamage, ), - //new LobbyComponent($arena); + GameState::PRE_GAME => array( $stopEveryThing, $noDamage, $joinSpectate), - $worldComponent = new WorldComponent($arena); + GameState::GAME => array( $stopEveryThing, $joinSpectate , new DeathSpectate($arena, $spectateComponent)), - $spawnComponent = new SimpleSpawnComponent($arena, $worldComponent); + GameState::POST_GAME => array($stopEveryThing, $noDamage, $joinSpectate), - new SpawnAt($arena, $spawnComponent, [GameState::PRE_GAME]); + ); - new LobbyCountdown($arena, $gameStateComponent, $worldComponent, GameState::LOBBY, GameState::PRE_GAME, 10, 1); + new GameStateFeatureManager($arena, $features); - //new GameStateCountdown($arena, $gameStateComponent, 10, GameState::PRE_GAME, GameState::GAME); + //new LobbyCountdown( $arena, $gameStateComponent, null, GameState::LOBBY, GameState::PRE_GAME, 10, 2); - //new GameStateCountdown($arena, $gameStateComponent, 20, GameState::GAME, GameState::POST_GAME); + new GameStateCountdown($arena, $gameStateComponent, 5, GameState::LOBBY, GameState::PRE_GAME); - //new GameStateCountdown($arena, $gameStateComponent, 10, GameState::POST_GAME, GameState::RESTARTING); + new GameStateCountdown($arena, $gameStateComponent, 5, GameState::PRE_GAME, GameState::GAME); + + new GameStateCountdown($arena, $gameStateComponent, 5, GameState::GAME, GameState::POST_GAME); + //new LMSVictoryType( $arena, $spectateComponent, $gameStateComponent); + + new GameStateCountdown($arena, $gameStateComponent, 5, GameState::POST_GAME, GameState::RESTARTING); } } \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilArray.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilArray.php index f630a6f37..aaf6f4bd6 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilArray.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilArray.php @@ -51,4 +51,12 @@ class UtilArray { return $returnArray; } -} \ No newline at end of file +} +/* +$obj1 = new \stdClass(); +$a1=array("a"=>$obj1,"b"=>"green","c"=>"blue"); +$a2=array("d"=>$obj1,"b"=>"black","e"=>"blue"); +$result=UtilArray::arrayDiff($a1,$a2); +print_r($result); +print "hi"; +*/ \ No newline at end of file diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilFile.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilFile.php index c0c4b9909..8fa9cb409 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilFile.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilFile.php @@ -8,23 +8,20 @@ class UtilFile { if (! is_dir($dirPath)) { - throw new InvalidArgumentException("$dirPath must be a directory"); + unlink($dirPath); + return; } + if (substr($dirPath, strlen($dirPath) - 1, 1) != '/') { $dirPath .= '/'; } + $files = glob($dirPath . '*', GLOB_MARK); + foreach ($files as $file) { - if (is_dir($file)) - { - self::deleteDir($file); - } - else - { - unlink($file); - } + self::deleteDir($file); } rmdir($dirPath); } diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilTeleport.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilTeleport.php new file mode 100644 index 000000000..b322c7929 --- /dev/null +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilTeleport.php @@ -0,0 +1,84 @@ +noDamageTicks = 20; + + //$player->teleport($pos); + + $current = $player->getLevel(); + + if ($current->getName() != $pos->getLevel()) { + + foreach ($pos->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 + + $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); + } +} \ No newline at end of file