Moo
Signed-off-by: Aaron Brock <TheMineBench@gmail.com>
This commit is contained in:
parent
b89cc7818c
commit
547d496853
@ -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);
|
||||
print_r($a1);
|
@ -83,7 +83,6 @@ class MultiGameArena implements Arena, Listener
|
||||
Server::getInstance()->getPluginManager()->callEvent(new ArenaStartEvent($this));
|
||||
}
|
||||
|
||||
|
||||
public function getPlayers()
|
||||
{
|
||||
return $this->players;
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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)
|
||||
);
|
||||
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user