Signed-off-by: Aaron Brock <TheMineBench@gmail.com>
This commit is contained in:
Aaron Brock 2015-07-06 22:22:14 -04:00
parent b89cc7818c
commit 547d496853
6 changed files with 35 additions and 24 deletions

View File

@ -7,17 +7,9 @@
*/ */
function myfunction($a,$b) $a1 = array();
{ $a2 = array($a1);
if ($a===$b)
{
return 0;
}
return ($a>$b)?1:-1;
}
$a1=array(new stdClass(),"b"=>"green","c"=>"blue"); array_push($a1, $a2);
$a2=array("a"=>"blue","b"=>"black","e"=>"blue");
$result=array_udiff($a1,$a2,"myfunction"); print_r($a1);
print_r($result);

View File

@ -83,7 +83,6 @@ class MultiGameArena implements Arena, Listener
Server::getInstance()->getPluginManager()->callEvent(new ArenaStartEvent($this)); Server::getInstance()->getPluginManager()->callEvent(new ArenaStartEvent($this));
} }
public function getPlayers() public function getPlayers()
{ {
return $this->players; return $this->players;

View File

@ -48,7 +48,7 @@ class NoPickUpItem extends ListenerFeature {
Server::getInstance()->broadcastMessage("Stopped!"); Server::getInstance()->broadcastMessage("Stopped!");
} else } else
Server::getInstance()->broadcastMessage("Not Stopped!"); Server::getInstance()->broadcastMessage("Not Stopped!");
} }

View File

@ -26,11 +26,11 @@ class GameStateFeatureManager implements Listener {
private $arena; private $arena;
/** @var Feature[][] */ /** @var Feature[][] */
private $features; private $features = [];
/** /**
* @param Arena $arena * @param Arena $arena
* @param Feature[][] $features * @param Feature[] $features
*/ */
public function __construct(Arena $arena, array $features) public function __construct(Arena $arena, array $features)
{ {
@ -38,7 +38,10 @@ class GameStateFeatureManager implements Listener {
unset ($features[GameState::RESTARTING]); 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()); Server::getInstance()->getPluginManager()->registerEvents($this, $arena->getPlugin());
} }

View File

@ -36,17 +36,13 @@ class SurvivalGames implements Game {
//Init features //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); $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 */ /** @var Feature[][] $features */
$features = array( $features = array(
GameState::LOBBY => array($noBlockBreak, $noBlockPlace, $noDropItem, $noPickUpItem) GameState::LOBBY => array($noPickUpItem, $pack)
); );

View File

@ -30,4 +30,25 @@ class UtilArray {
} }
return ($a>$b)?1:-1; 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;
}
} }