Skip to content

Commit

Permalink
Simplified some logic and added __toString to Mine
Browse files Browse the repository at this point in the history
  • Loading branch information
falkirks committed Apr 25, 2017
1 parent 61cfd11 commit 0150038
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
3 changes: 3 additions & 0 deletions src/falkirks/minereset/Mine.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,4 +144,7 @@ public function doneReset(){
$this->isResetting = false;
}

public function __toString(){
return $this->name;
}
}
22 changes: 6 additions & 16 deletions src/falkirks/minereset/MineManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,22 +154,12 @@ protected function mineFromData($name, array $array){
if(!$this->getApi()->getServer()->isLevelLoaded($array[7])){
$this->api->getLogger()->warning("A mine with the name " . TextFormat::AQUA . $name . TextFormat::RESET . " is connected to a level which is not loaded. You won't be able to use it until you load the level correctly.");
}

if(is_array($array[6])) {
return new Mine($this,
new Vector3(min($array[0], $array[1]), min($array[2], $array[3]), min($array[4], $array[5])),
new Vector3(max($array[0], $array[1]), max($array[2], $array[3]), max($array[4], $array[5])),
$array[7],
$name,
$array[6]);
}
else{
return new Mine($this,
new Vector3(min($array[0], $array[1]), min($array[2], $array[3]), min($array[4], $array[5])),
new Vector3(max($array[0], $array[1]), max($array[2], $array[3]), max($array[4], $array[5])),
$array[7],
$name);
}
return new Mine($this,
new Vector3(min($array[0], $array[1]), min($array[2], $array[3]), min($array[4], $array[5])),
new Vector3(max($array[0], $array[1]), max($array[2], $array[3]), max($array[4], $array[5])),
$array[7],
$name,
$array[6] ?? []);
}
$this->api->getLogger()->critical("A mine with the name " . TextFormat::AQUA . $name . TextFormat::RESET . " is incomplete. It will be removed automatically when your server stops.");
return null;
Expand Down

0 comments on commit 0150038

Please sign in to comment.