mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-07 10:22:56 +00:00
Critical error upon missing submodules (#77)
* Critical error upon missing SPL * Added checks for RakLib and PocketMine-Language * It actually throws ClassNotFoundException, not simply returns false :( Should I blame :shoghi:?
This commit is contained in:
@ -23,6 +23,7 @@ namespace pocketmine\lang;
|
||||
|
||||
use pocketmine\event\TextContainer;
|
||||
use pocketmine\event\TranslationContainer;
|
||||
use pocketmine\Server;
|
||||
|
||||
class BaseLang{
|
||||
|
||||
@ -41,8 +42,12 @@ class BaseLang{
|
||||
$path = \pocketmine\PATH . "src/pocketmine/lang/locale/";
|
||||
}
|
||||
|
||||
$this->loadLang($path . $this->langName . ".ini", $this->lang);
|
||||
$this->loadLang($path . $fallback . ".ini", $this->fallbackLang);
|
||||
if(!$this->loadLang($file = $path . $this->langName . ".ini", $this->lang)){
|
||||
Server::getInstance()->getLogger()->error("Missing required language file $file");
|
||||
}
|
||||
if(!$this->loadLang($file = $path . $fallback . ".ini", $this->fallbackLang)){
|
||||
Server::getInstance()->getLogger()->error("Missing required language file $file");
|
||||
}
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
@ -54,27 +59,32 @@ class BaseLang{
|
||||
}
|
||||
|
||||
protected function loadLang($path, array &$d){
|
||||
if(file_exists($path) and strlen($content = file_get_contents($path)) > 0){
|
||||
foreach(explode("\n", $content) as $line){
|
||||
$line = trim($line);
|
||||
if($line === "" or $line{0} === "#"){
|
||||
continue;
|
||||
if(file_exists($path)){
|
||||
if(strlen($content = file_get_contents($path)) > 0){
|
||||
foreach(explode("\n", $content) as $line){
|
||||
$line = trim($line);
|
||||
if($line === "" or $line{0} === "#"){
|
||||
continue;
|
||||
}
|
||||
|
||||
$t = explode("=", $line, 2);
|
||||
if(count($t) < 2){
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = trim($t[0]);
|
||||
$value = trim($t[1]);
|
||||
|
||||
if($value === ""){
|
||||
continue;
|
||||
}
|
||||
|
||||
$d[$key] = $value;
|
||||
}
|
||||
|
||||
$t = explode("=", $line, 2);
|
||||
if(count($t) < 2){
|
||||
continue;
|
||||
}
|
||||
|
||||
$key = trim($t[0]);
|
||||
$value = trim($t[1]);
|
||||
|
||||
if($value === ""){
|
||||
continue;
|
||||
}
|
||||
|
||||
$d[$key] = $value;
|
||||
}
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user