mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-17 03:08:58 +00:00
Moved exception handler to a big try catch
This commit is contained in:
parent
e137ac4c56
commit
922e9d93d5
@ -1445,9 +1445,7 @@ class Server{
|
|||||||
|
|
||||||
public static function microSleep(int $microseconds){
|
public static function microSleep(int $microseconds){
|
||||||
Server::$sleeper->synchronized(function(int $ms){
|
Server::$sleeper->synchronized(function(int $ms){
|
||||||
var_dump("Sleeping $ms");
|
|
||||||
Server::$sleeper->wait($ms);
|
Server::$sleeper->wait($ms);
|
||||||
var_dump("Finished sleep $ms");
|
|
||||||
}, $microseconds);
|
}, $microseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1461,255 +1459,259 @@ class Server{
|
|||||||
public function __construct(\ClassLoader $autoloader, \ThreadedLogger $logger, $filePath, $dataPath, $pluginPath){
|
public function __construct(\ClassLoader $autoloader, \ThreadedLogger $logger, $filePath, $dataPath, $pluginPath){
|
||||||
self::$instance = $this;
|
self::$instance = $this;
|
||||||
self::$sleeper = \ThreadedFactory::create();
|
self::$sleeper = \ThreadedFactory::create();
|
||||||
|
|
||||||
$this->autoloader = $autoloader;
|
$this->autoloader = $autoloader;
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->filePath = $filePath;
|
|
||||||
if(!file_exists($dataPath . "worlds/")){
|
|
||||||
mkdir($dataPath . "worlds/", 0777);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!file_exists($dataPath . "players/")){
|
try{
|
||||||
mkdir($dataPath . "players/", 0777);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(!file_exists($pluginPath)){
|
$this->filePath = $filePath;
|
||||||
mkdir($pluginPath, 0777);
|
if(!file_exists($dataPath . "worlds/")){
|
||||||
}
|
mkdir($dataPath . "worlds/", 0777);
|
||||||
|
|
||||||
$this->dataPath = realpath($dataPath) . DIRECTORY_SEPARATOR;
|
|
||||||
$this->pluginPath = realpath($pluginPath) . DIRECTORY_SEPARATOR;
|
|
||||||
|
|
||||||
$this->console = new CommandReader();
|
|
||||||
|
|
||||||
$version = new VersionString($this->getPocketMineVersion());
|
|
||||||
|
|
||||||
$this->logger->info("Loading pocketmine.yml...");
|
|
||||||
if(!file_exists($this->dataPath . "pocketmine.yml")){
|
|
||||||
$content = file_get_contents($this->filePath . "src/pocketmine/resources/pocketmine.yml");
|
|
||||||
if($version->isDev()){
|
|
||||||
$content = str_replace("preferred-channel: stable", "preferred-channel: beta", $content);
|
|
||||||
}
|
}
|
||||||
@file_put_contents($this->dataPath . "pocketmine.yml", $content);
|
|
||||||
}
|
|
||||||
$this->config = new Config($this->dataPath . "pocketmine.yml", Config::YAML, []);
|
|
||||||
|
|
||||||
$this->logger->info("Loading server properties...");
|
if(!file_exists($dataPath . "players/")){
|
||||||
$this->properties = new Config($this->dataPath . "server.properties", Config::PROPERTIES, [
|
mkdir($dataPath . "players/", 0777);
|
||||||
"motd" => "Minecraft: PE Server",
|
|
||||||
"server-port" => 19132,
|
|
||||||
"white-list" => false,
|
|
||||||
"announce-player-achievements" => true,
|
|
||||||
"spawn-protection" => 16,
|
|
||||||
"max-players" => 20,
|
|
||||||
"allow-flight" => false,
|
|
||||||
"spawn-animals" => true,
|
|
||||||
"spawn-mobs" => true,
|
|
||||||
"gamemode" => 0,
|
|
||||||
"force-gamemode" => false,
|
|
||||||
"hardcore" => false,
|
|
||||||
"pvp" => true,
|
|
||||||
"difficulty" => 1,
|
|
||||||
"generator-settings" => "",
|
|
||||||
"level-name" => "world",
|
|
||||||
"level-seed" => "",
|
|
||||||
"level-type" => "DEFAULT",
|
|
||||||
"enable-query" => true,
|
|
||||||
"enable-rcon" => false,
|
|
||||||
"rcon.password" => substr(base64_encode(@Utils::getRandomBytes(20, false)), 3, 10),
|
|
||||||
"auto-save" => true,
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->forceLanguage = $this->getProperty("settings.force-language", false);
|
|
||||||
$this->baseLang = new BaseLang($this->getProperty("settings.language", BaseLang::FALLBACK_LANGUAGE));
|
|
||||||
$this->logger->info($this->getLanguage()->translateString("language.selected", [$this->getLanguage()->getName(), $this->getLanguage()->getLang()]));
|
|
||||||
|
|
||||||
$this->memoryManager = new MemoryManager($this);
|
|
||||||
|
|
||||||
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.start", [TextFormat::AQUA . $this->getVersion()]));
|
|
||||||
|
|
||||||
if(($poolSize = $this->getProperty("settings.async-workers", "auto")) === "auto"){
|
|
||||||
$poolSize = ServerScheduler::$WORKERS;
|
|
||||||
$processors = Utils::getCoreCount() - 2;
|
|
||||||
|
|
||||||
if($processors > 0){
|
|
||||||
$poolSize = max(1, $processors);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ServerScheduler::$WORKERS = $poolSize;
|
if(!file_exists($pluginPath)){
|
||||||
|
mkdir($pluginPath, 0777);
|
||||||
|
}
|
||||||
|
|
||||||
if($this->getProperty("network.batch-threshold", 256) >= 0){
|
$this->dataPath = realpath($dataPath) . DIRECTORY_SEPARATOR;
|
||||||
Network::$BATCH_THRESHOLD = (int) $this->getProperty("network.batch-threshold", 256);
|
$this->pluginPath = realpath($pluginPath) . DIRECTORY_SEPARATOR;
|
||||||
}else{
|
|
||||||
Network::$BATCH_THRESHOLD = -1;
|
|
||||||
}
|
|
||||||
$this->networkCompressionLevel = $this->getProperty("network.compression-level", 7);
|
|
||||||
$this->networkCompressionAsync = $this->getProperty("network.async-compression", true);
|
|
||||||
|
|
||||||
$this->autoTickRate = (bool) $this->getProperty("level-settings.auto-tick-rate", true);
|
$this->console = new CommandReader();
|
||||||
$this->autoTickRateLimit = (int) $this->getProperty("level-settings.auto-tick-rate-limit", 20);
|
|
||||||
$this->alwaysTickPlayers = (int) $this->getProperty("level-settings.always-tick-players", false);
|
|
||||||
$this->baseTickRate = (int) $this->getProperty("level-settings.base-tick-rate", 1);
|
|
||||||
|
|
||||||
$this->scheduler = new ServerScheduler();
|
$version = new VersionString($this->getPocketMineVersion());
|
||||||
|
|
||||||
if($this->getConfigBoolean("enable-rcon", false) === true){
|
$this->logger->info("Loading pocketmine.yml...");
|
||||||
$this->rcon = new RCON($this, $this->getConfigString("rcon.password", ""), $this->getConfigInt("rcon.port", $this->getPort()), ($ip = $this->getIp()) != "" ? $ip : "0.0.0.0", $this->getConfigInt("rcon.threads", 1), $this->getConfigInt("rcon.clients-per-thread", 50));
|
if(!file_exists($this->dataPath . "pocketmine.yml")){
|
||||||
}
|
$content = file_get_contents($this->filePath . "src/pocketmine/resources/pocketmine.yml");
|
||||||
|
if($version->isDev()){
|
||||||
|
$content = str_replace("preferred-channel: stable", "preferred-channel: beta", $content);
|
||||||
|
}
|
||||||
|
@file_put_contents($this->dataPath . "pocketmine.yml", $content);
|
||||||
|
}
|
||||||
|
$this->config = new Config($this->dataPath . "pocketmine.yml", Config::YAML, []);
|
||||||
|
|
||||||
$this->entityMetadata = new EntityMetadataStore();
|
$this->logger->info("Loading server properties...");
|
||||||
$this->playerMetadata = new PlayerMetadataStore();
|
$this->properties = new Config($this->dataPath . "server.properties", Config::PROPERTIES, [
|
||||||
$this->levelMetadata = new LevelMetadataStore();
|
"motd" => "Minecraft: PE Server",
|
||||||
|
"server-port" => 19132,
|
||||||
|
"white-list" => false,
|
||||||
|
"announce-player-achievements" => true,
|
||||||
|
"spawn-protection" => 16,
|
||||||
|
"max-players" => 20,
|
||||||
|
"allow-flight" => false,
|
||||||
|
"spawn-animals" => true,
|
||||||
|
"spawn-mobs" => true,
|
||||||
|
"gamemode" => 0,
|
||||||
|
"force-gamemode" => false,
|
||||||
|
"hardcore" => false,
|
||||||
|
"pvp" => true,
|
||||||
|
"difficulty" => 1,
|
||||||
|
"generator-settings" => "",
|
||||||
|
"level-name" => "world",
|
||||||
|
"level-seed" => "",
|
||||||
|
"level-type" => "DEFAULT",
|
||||||
|
"enable-query" => true,
|
||||||
|
"enable-rcon" => false,
|
||||||
|
"rcon.password" => substr(base64_encode(@Utils::getRandomBytes(20, false)), 3, 10),
|
||||||
|
"auto-save" => true,
|
||||||
|
]);
|
||||||
|
|
||||||
$this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM);
|
$this->forceLanguage = $this->getProperty("settings.force-language", false);
|
||||||
$this->whitelist = new Config($this->dataPath . "white-list.txt", Config::ENUM);
|
$this->baseLang = new BaseLang($this->getProperty("settings.language", BaseLang::FALLBACK_LANGUAGE));
|
||||||
if(file_exists($this->dataPath . "banned.txt") and !file_exists($this->dataPath . "banned-players.txt")){
|
$this->logger->info($this->getLanguage()->translateString("language.selected", [$this->getLanguage()->getName(), $this->getLanguage()->getLang()]));
|
||||||
@rename($this->dataPath . "banned.txt", $this->dataPath . "banned-players.txt");
|
|
||||||
}
|
|
||||||
@touch($this->dataPath . "banned-players.txt");
|
|
||||||
$this->banByName = new BanList($this->dataPath . "banned-players.txt");
|
|
||||||
$this->banByName->load();
|
|
||||||
@touch($this->dataPath . "banned-ips.txt");
|
|
||||||
$this->banByIP = new BanList($this->dataPath . "banned-ips.txt");
|
|
||||||
$this->banByIP->load();
|
|
||||||
|
|
||||||
$this->maxPlayers = $this->getConfigInt("max-players", 20);
|
$this->memoryManager = new MemoryManager($this);
|
||||||
$this->setAutoSave($this->getConfigBoolean("auto-save", true));
|
|
||||||
|
|
||||||
if($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3){
|
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.start", [TextFormat::AQUA . $this->getVersion()]));
|
||||||
$this->setConfigInt("difficulty", 3);
|
|
||||||
}
|
|
||||||
|
|
||||||
define("pocketmine\\DEBUG", (int) $this->getProperty("debug.level", 1));
|
if(($poolSize = $this->getProperty("settings.async-workers", "auto")) === "auto"){
|
||||||
if($this->logger instanceof MainLogger){
|
$poolSize = ServerScheduler::$WORKERS;
|
||||||
$this->logger->setLogDebug(\pocketmine\DEBUG > 1);
|
$processors = Utils::getCoreCount() - 2;
|
||||||
}
|
|
||||||
|
|
||||||
if(\pocketmine\DEBUG >= 0){
|
if($processors > 0){
|
||||||
@cli_set_process_title($this->getName() . " " . $this->getPocketMineVersion());
|
$poolSize = max(1, $processors);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.networkStart", [$this->getIp() === "" ? "*" : $this->getIp(), $this->getPort()]));
|
ServerScheduler::$WORKERS = $poolSize;
|
||||||
define("BOOTUP_RANDOM", @Utils::getRandomBytes(16));
|
|
||||||
$this->serverID = Utils::getMachineUniqueId($this->getIp() . $this->getPort());
|
|
||||||
|
|
||||||
$this->getLogger()->debug("Server unique id: " . $this->getServerUniqueId());
|
if($this->getProperty("network.batch-threshold", 256) >= 0){
|
||||||
$this->getLogger()->debug("Machine unique id: " . Utils::getMachineUniqueId());
|
Network::$BATCH_THRESHOLD = (int) $this->getProperty("network.batch-threshold", 256);
|
||||||
|
}else{
|
||||||
|
Network::$BATCH_THRESHOLD = -1;
|
||||||
|
}
|
||||||
|
$this->networkCompressionLevel = $this->getProperty("network.compression-level", 7);
|
||||||
|
$this->networkCompressionAsync = $this->getProperty("network.async-compression", true);
|
||||||
|
|
||||||
$this->network = new Network($this);
|
$this->autoTickRate = (bool) $this->getProperty("level-settings.auto-tick-rate", true);
|
||||||
$this->network->setName($this->getMotd());
|
$this->autoTickRateLimit = (int) $this->getProperty("level-settings.auto-tick-rate-limit", 20);
|
||||||
|
$this->alwaysTickPlayers = (int) $this->getProperty("level-settings.always-tick-players", false);
|
||||||
|
$this->baseTickRate = (int) $this->getProperty("level-settings.base-tick-rate", 1);
|
||||||
|
|
||||||
|
$this->scheduler = new ServerScheduler();
|
||||||
|
|
||||||
|
if($this->getConfigBoolean("enable-rcon", false) === true){
|
||||||
|
$this->rcon = new RCON($this, $this->getConfigString("rcon.password", ""), $this->getConfigInt("rcon.port", $this->getPort()), ($ip = $this->getIp()) != "" ? $ip : "0.0.0.0", $this->getConfigInt("rcon.threads", 1), $this->getConfigInt("rcon.clients-per-thread", 50));
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->entityMetadata = new EntityMetadataStore();
|
||||||
|
$this->playerMetadata = new PlayerMetadataStore();
|
||||||
|
$this->levelMetadata = new LevelMetadataStore();
|
||||||
|
|
||||||
|
$this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM);
|
||||||
|
$this->whitelist = new Config($this->dataPath . "white-list.txt", Config::ENUM);
|
||||||
|
if(file_exists($this->dataPath . "banned.txt") and !file_exists($this->dataPath . "banned-players.txt")){
|
||||||
|
@rename($this->dataPath . "banned.txt", $this->dataPath . "banned-players.txt");
|
||||||
|
}
|
||||||
|
@touch($this->dataPath . "banned-players.txt");
|
||||||
|
$this->banByName = new BanList($this->dataPath . "banned-players.txt");
|
||||||
|
$this->banByName->load();
|
||||||
|
@touch($this->dataPath . "banned-ips.txt");
|
||||||
|
$this->banByIP = new BanList($this->dataPath . "banned-ips.txt");
|
||||||
|
$this->banByIP->load();
|
||||||
|
|
||||||
|
$this->maxPlayers = $this->getConfigInt("max-players", 20);
|
||||||
|
$this->setAutoSave($this->getConfigBoolean("auto-save", true));
|
||||||
|
|
||||||
|
if($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3){
|
||||||
|
$this->setConfigInt("difficulty", 3);
|
||||||
|
}
|
||||||
|
|
||||||
|
define("pocketmine\\DEBUG", (int) $this->getProperty("debug.level", 1));
|
||||||
|
if($this->logger instanceof MainLogger){
|
||||||
|
$this->logger->setLogDebug(\pocketmine\DEBUG > 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(\pocketmine\DEBUG >= 0){
|
||||||
|
@cli_set_process_title($this->getName() . " " . $this->getPocketMineVersion());
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.networkStart", [$this->getIp() === "" ? "*" : $this->getIp(), $this->getPort()]));
|
||||||
|
define("BOOTUP_RANDOM", @Utils::getRandomBytes(16));
|
||||||
|
$this->serverID = Utils::getMachineUniqueId($this->getIp() . $this->getPort());
|
||||||
|
|
||||||
|
$this->getLogger()->debug("Server unique id: " . $this->getServerUniqueId());
|
||||||
|
$this->getLogger()->debug("Machine unique id: " . Utils::getMachineUniqueId());
|
||||||
|
|
||||||
|
$this->network = new Network($this);
|
||||||
|
$this->network->setName($this->getMotd());
|
||||||
|
|
||||||
|
|
||||||
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.info", [
|
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.info", [
|
||||||
$this->getName(),
|
$this->getName(),
|
||||||
($version->isDev() ? TextFormat::YELLOW : "") . $version->get(true) . TextFormat::WHITE,
|
($version->isDev() ? TextFormat::YELLOW : "") . $version->get(true) . TextFormat::WHITE,
|
||||||
$this->getCodename(),
|
$this->getCodename(),
|
||||||
$this->getApiVersion()
|
$this->getApiVersion()
|
||||||
]));
|
]));
|
||||||
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.license", [$this->getName()]));
|
$this->logger->info($this->getLanguage()->translateString("pocketmine.server.license", [$this->getName()]));
|
||||||
|
|
||||||
Timings::init();
|
Timings::init();
|
||||||
|
|
||||||
$this->consoleSender = new ConsoleCommandSender();
|
$this->consoleSender = new ConsoleCommandSender();
|
||||||
$this->commandMap = new SimpleCommandMap($this);
|
$this->commandMap = new SimpleCommandMap($this);
|
||||||
|
|
||||||
$this->registerEntities();
|
$this->registerEntities();
|
||||||
$this->registerTiles();
|
$this->registerTiles();
|
||||||
|
|
||||||
InventoryType::init();
|
InventoryType::init();
|
||||||
Block::init();
|
Block::init();
|
||||||
Item::init();
|
Item::init();
|
||||||
Biome::init();
|
Biome::init();
|
||||||
Effect::init();
|
Effect::init();
|
||||||
Enchantment::init();
|
Enchantment::init();
|
||||||
Attribute::init();
|
Attribute::init();
|
||||||
/** TODO: @deprecated */
|
/** TODO: @deprecated */
|
||||||
TextWrapper::init();
|
TextWrapper::init();
|
||||||
$this->craftingManager = new CraftingManager();
|
$this->craftingManager = new CraftingManager();
|
||||||
|
|
||||||
$this->pluginManager = new PluginManager($this, $this->commandMap);
|
$this->pluginManager = new PluginManager($this, $this->commandMap);
|
||||||
$this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender);
|
$this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender);
|
||||||
$this->pluginManager->setUseTimings($this->getProperty("settings.enable-profiling", false));
|
$this->pluginManager->setUseTimings($this->getProperty("settings.enable-profiling", false));
|
||||||
$this->profilingTickRate = (float) $this->getProperty("settings.profile-report-trigger", 20);
|
$this->profilingTickRate = (float) $this->getProperty("settings.profile-report-trigger", 20);
|
||||||
$this->pluginManager->registerInterface(PharPluginLoader::class);
|
$this->pluginManager->registerInterface(PharPluginLoader::class);
|
||||||
$this->pluginManager->registerInterface(ScriptPluginLoader::class);
|
$this->pluginManager->registerInterface(ScriptPluginLoader::class);
|
||||||
|
|
||||||
set_exception_handler([$this, "exceptionHandler"]);
|
register_shutdown_function([$this, "crashDump"]);
|
||||||
register_shutdown_function([$this, "crashDump"]);
|
|
||||||
|
|
||||||
$this->queryRegenerateTask = new QueryRegenerateEvent($this, 5);
|
$this->queryRegenerateTask = new QueryRegenerateEvent($this, 5);
|
||||||
$this->network->registerInterface(new RakLibInterface($this));
|
$this->network->registerInterface(new RakLibInterface($this));
|
||||||
|
|
||||||
$this->pluginManager->loadPlugins($this->pluginPath);
|
$this->pluginManager->loadPlugins($this->pluginPath);
|
||||||
|
|
||||||
$this->updater = new AutoUpdater($this, $this->getProperty("auto-updater.host", "www.pocketmine.net"));
|
$this->updater = new AutoUpdater($this, $this->getProperty("auto-updater.host", "www.pocketmine.net"));
|
||||||
|
|
||||||
$this->enablePlugins(PluginLoadOrder::STARTUP);
|
$this->enablePlugins(PluginLoadOrder::STARTUP);
|
||||||
|
|
||||||
LevelProviderManager::addProvider($this, Anvil::class);
|
LevelProviderManager::addProvider($this, Anvil::class);
|
||||||
LevelProviderManager::addProvider($this, McRegion::class);
|
LevelProviderManager::addProvider($this, McRegion::class);
|
||||||
if(extension_loaded("leveldb")){
|
if(extension_loaded("leveldb")){
|
||||||
$this->logger->debug($this->getLanguage()->translateString("pocketmine.debug.enable"));
|
$this->logger->debug($this->getLanguage()->translateString("pocketmine.debug.enable"));
|
||||||
LevelProviderManager::addProvider($this, LevelDB::class);
|
LevelProviderManager::addProvider($this, LevelDB::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Generator::addGenerator(Flat::class, "flat");
|
Generator::addGenerator(Flat::class, "flat");
|
||||||
Generator::addGenerator(Normal::class, "normal");
|
Generator::addGenerator(Normal::class, "normal");
|
||||||
Generator::addGenerator(Normal::class, "default");
|
Generator::addGenerator(Normal::class, "default");
|
||||||
Generator::addGenerator(Nether::class, "hell");
|
Generator::addGenerator(Nether::class, "hell");
|
||||||
Generator::addGenerator(Nether::class, "nether");
|
Generator::addGenerator(Nether::class, "nether");
|
||||||
|
|
||||||
foreach((array) $this->getProperty("worlds", []) as $name => $worldSetting){
|
foreach((array) $this->getProperty("worlds", []) as $name => $worldSetting){
|
||||||
if($this->loadLevel($name) === false){
|
if($this->loadLevel($name) === false){
|
||||||
$seed = $this->getProperty("worlds.$name.seed", time());
|
$seed = $this->getProperty("worlds.$name.seed", time());
|
||||||
$options = explode(":", $this->getProperty("worlds.$name.generator", Generator::getGenerator("default")));
|
$options = explode(":", $this->getProperty("worlds.$name.generator", Generator::getGenerator("default")));
|
||||||
$generator = Generator::getGenerator(array_shift($options));
|
$generator = Generator::getGenerator(array_shift($options));
|
||||||
if(count($options) > 0){
|
if(count($options) > 0){
|
||||||
$options = [
|
$options = [
|
||||||
"preset" => implode(":", $options),
|
"preset" => implode(":", $options),
|
||||||
];
|
];
|
||||||
}else{
|
}else{
|
||||||
$options = [];
|
$options = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->generateLevel($name, $seed, $generator, $options);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getDefaultLevel() === null){
|
||||||
|
$default = $this->getConfigString("level-name", "world");
|
||||||
|
if(trim($default) == ""){
|
||||||
|
$this->getLogger()->warning("level-name cannot be null, using default");
|
||||||
|
$default = "world";
|
||||||
|
$this->setConfigString("level-name", "world");
|
||||||
|
}
|
||||||
|
if($this->loadLevel($default) === false){
|
||||||
|
$seed = $this->getConfigInt("level-seed", time());
|
||||||
|
$this->generateLevel($default, $seed === 0 ? time() : $seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->generateLevel($name, $seed, $generator, $options);
|
$this->setDefaultLevel($this->getLevelByName($default));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->getDefaultLevel() === null){
|
|
||||||
$default = $this->getConfigString("level-name", "world");
|
|
||||||
if(trim($default) == ""){
|
|
||||||
$this->getLogger()->warning("level-name cannot be null, using default");
|
|
||||||
$default = "world";
|
|
||||||
$this->setConfigString("level-name", "world");
|
|
||||||
}
|
|
||||||
if($this->loadLevel($default) === false){
|
|
||||||
$seed = $this->getConfigInt("level-seed", time());
|
|
||||||
$this->generateLevel($default, $seed === 0 ? time() : $seed);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->setDefaultLevel($this->getLevelByName($default));
|
|
||||||
|
$this->properties->save(true);
|
||||||
|
|
||||||
|
if(!($this->getDefaultLevel() instanceof Level)){
|
||||||
|
$this->getLogger()->emergency($this->getLanguage()->translateString("pocketmine.level.defaultError"));
|
||||||
|
$this->forceShutdown();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getProperty("ticks-per.autosave", 6000) > 0){
|
||||||
|
$this->autoSaveTicks = (int) $this->getProperty("ticks-per.autosave", 6000);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->enablePlugins(PluginLoadOrder::POSTWORLD);
|
||||||
|
|
||||||
|
$this->start();
|
||||||
|
}catch(\Throwable $e){
|
||||||
|
$this->exceptionHandler($e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$this->properties->save(true);
|
|
||||||
|
|
||||||
if(!($this->getDefaultLevel() instanceof Level)){
|
|
||||||
$this->getLogger()->emergency($this->getLanguage()->translateString("pocketmine.level.defaultError"));
|
|
||||||
$this->forceShutdown();
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($this->getProperty("ticks-per.autosave", 6000) > 0){
|
|
||||||
$this->autoSaveTicks = (int) $this->getProperty("ticks-per.autosave", 6000);
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->enablePlugins(PluginLoadOrder::POSTWORLD);
|
|
||||||
|
|
||||||
$this->start();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user