From 547d49685343561b172bb3e084dc2951c2bd79e8 Mon Sep 17 00:00:00 2001 From: Aaron Brock Date: Mon, 6 Jul 2015 22:22:14 -0400 Subject: [PATCH] Moo Signed-off-by: Aaron Brock --- Pocket/plugins/Mineplex/src/Test.php | 16 ++++---------- .../gameengine/arenas/MultiGameArena.php | 1 - .../feature/features/NoPickUpItem.php | 2 +- .../managers/GameStateFeatureManager.php | 9 +++++--- .../game/games/sg/SurvivalGames.php | 10 +++------ .../src/mineplex/plugin/util/UtilArray.php | 21 +++++++++++++++++++ 6 files changed, 35 insertions(+), 24 deletions(-) diff --git a/Pocket/plugins/Mineplex/src/Test.php b/Pocket/plugins/Mineplex/src/Test.php index 7775713b2..42337416e 100644 --- a/Pocket/plugins/Mineplex/src/Test.php +++ b/Pocket/plugins/Mineplex/src/Test.php @@ -7,17 +7,9 @@ */ -function myfunction($a,$b) -{ - if ($a===$b) - { - return 0; - } - return ($a>$b)?1:-1; -} +$a1 = array(); +$a2 = array($a1); -$a1=array(new stdClass(),"b"=>"green","c"=>"blue"); -$a2=array("a"=>"blue","b"=>"black","e"=>"blue"); +array_push($a1, $a2); -$result=array_udiff($a1,$a2,"myfunction"); -print_r($result); \ No newline at end of file +print_r($a1); \ No newline at end of file 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 30f7d0b69..5ae4372c3 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/arenas/MultiGameArena.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/arenas/MultiGameArena.php @@ -83,7 +83,6 @@ class MultiGameArena implements Arena, Listener Server::getInstance()->getPluginManager()->callEvent(new ArenaStartEvent($this)); } - public function getPlayers() { return $this->players; diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/NoPickUpItem.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/NoPickUpItem.php index b307f6912..230143fc7 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/NoPickUpItem.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/gameengine/game/components/feature/features/NoPickUpItem.php @@ -48,7 +48,7 @@ class NoPickUpItem extends ListenerFeature { Server::getInstance()->broadcastMessage("Stopped!"); } else Server::getInstance()->broadcastMessage("Not Stopped!"); - + } 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 539c16f95..9d9cc03b9 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 @@ -26,11 +26,11 @@ class GameStateFeatureManager implements Listener { private $arena; /** @var Feature[][] */ - private $features; + private $features = []; /** * @param Arena $arena - * @param Feature[][] $features + * @param Feature[] $features */ public function __construct(Arena $arena, array $features) { @@ -38,7 +38,10 @@ class GameStateFeatureManager implements Listener { unset ($features[GameState::RESTARTING]); - $this->features = $features; + foreach ($features as $key => $value) + { + $this->features[$key] = UtilArray::getValuesRecursively($value); + } Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin()); } 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 4ddf5d21a..4832c2dca 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 @@ -36,17 +36,13 @@ class SurvivalGames implements Game { //Init features - $noBlockBreak = new NoBlockBreak($arena, [Item::GRASS]); - - $noBlockPlace = new NoBlockPlace($arena, [Item::WOOD], true); - - $noDropItem = new NoDropItem($arena, [Item::APPLE], true); - $noPickUpItem = new NoPickUpItem($arena, [Item::GRASS], true); + $pack = array(new NoBlockBreak($arena, [Item::GRASS]), new NoBlockPlace($arena, [Item::WOOD], true),new NoDropItem($arena, [Item::APPLE], true)); + /** @var Feature[][] $features */ $features = array( - GameState::LOBBY => array($noBlockBreak, $noBlockPlace, $noDropItem, $noPickUpItem) + GameState::LOBBY => array($noPickUpItem, $pack) ); diff --git a/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilArray.php b/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilArray.php index a7dbcdf0b..f630a6f37 100644 --- a/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilArray.php +++ b/Pocket/plugins/Mineplex/src/mineplex/plugin/util/UtilArray.php @@ -30,4 +30,25 @@ class UtilArray { } return ($a>$b)?1:-1; } + + public static function getValuesRecursively($object) + { + if (!is_array($object)) + return [$object]; + + $returnArray = []; + foreach ($object as $value) + { + if (is_array($value)) + { + $returnArray = array_merge($returnArray, array_values(self::getValuesRecursively($value))); + } + else + { + array_push($returnArray, $value); + } + } + return $returnArray; + } + } \ No newline at end of file