fixed worldconfig parsing
This commit is contained in:
parent
762772a079
commit
8cd5d9f7d0
@ -44,15 +44,18 @@ class SimpleSpawnComponent implements SpawnComponent, Listener {
|
|||||||
print "WorldLoadSuccessEvent!";
|
print "WorldLoadSuccessEvent!";
|
||||||
if ($event->getArena() !== $this->arena)
|
if ($event->getArena() !== $this->arena)
|
||||||
return;
|
return;
|
||||||
$this->spawns = UtilArray::getValuesRecursively($this->worldComponent->getTeams());
|
|
||||||
|
|
||||||
foreach ($this->spawns as $key => $value)
|
$this->spawns = $this->worldComponent->getTeams()['Green'];
|
||||||
{
|
|
||||||
if (!($value instanceof Position))
|
|
||||||
unset($this->spawns[$key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
print (count($this->spawns) . " spawns Loaded\n");
|
// $this->spawns = UtilArray::getValuesRecursively($this->worldComponent->getTeams());
|
||||||
|
//
|
||||||
|
// foreach ($this->spawns as $key => $value)
|
||||||
|
// {
|
||||||
|
// if (!($value instanceof Position))
|
||||||
|
// unset($this->spawns[$key]);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// print (count($this->spawns) . " spawns Loaded\n");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -80,12 +83,9 @@ class SimpleSpawnComponent implements SpawnComponent, Listener {
|
|||||||
Main::sendLoc($player);
|
Main::sendLoc($player);
|
||||||
|
|
||||||
$pos = $this->spawns[array_rand($this->spawns)];
|
$pos = $this->spawns[array_rand($this->spawns)];
|
||||||
$pos = $pos->getLevel()->getSpawnLocation();
|
//$pos = $pos->getLevel()->getSpawnLocation();
|
||||||
|
|
||||||
print "\nX: " . $pos->getX();
|
print_r($pos);
|
||||||
print "\nY: " . $pos->getY();
|
|
||||||
print "\nZ: " . $pos->getZ();
|
|
||||||
print "\nLevel: " . $pos->getLevel()->getName();
|
|
||||||
|
|
||||||
$player->teleport($pos);
|
$player->teleport($pos);
|
||||||
|
|
||||||
|
@ -145,7 +145,7 @@ class WorldComponent implements Listener
|
|||||||
|
|
||||||
public function loadWorldData()
|
public function loadWorldData()
|
||||||
{
|
{
|
||||||
$handle = fopen("WorldConfig.dat", "r");
|
$handle = fopen('worlds/' . $this->worldNameFolder . '/WorldConfig.dat', "r");
|
||||||
if ($handle)
|
if ($handle)
|
||||||
{
|
{
|
||||||
//These store the array that data should be inserted into
|
//These store the array that data should be inserted into
|
||||||
@ -155,7 +155,9 @@ class WorldComponent implements Listener
|
|||||||
|
|
||||||
while (($line = fgets($handle)) !== false)
|
while (($line = fgets($handle)) !== false)
|
||||||
{
|
{
|
||||||
$tokens = explode(":", $line);
|
$trimmedLine = trim($line, "\n\r");
|
||||||
|
|
||||||
|
$tokens = explode(":", $trimmedLine);
|
||||||
|
|
||||||
if (count($tokens) < 2 || strlen($tokens[0]) == 0)
|
if (count($tokens) < 2 || strlen($tokens[0]) == 0)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user