mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Some minor AutoUpdater cleanup, stop hardcoding everything
This commit is contained in:
parent
825d4f9702
commit
be27e03126
@ -89,15 +89,17 @@ class AutoUpdater{
|
||||
* Posts a warning to the console to tell the user there is an update available
|
||||
*/
|
||||
public function showConsoleUpdate(){
|
||||
$logger = $this->server->getLogger();
|
||||
$newVersion = new VersionString($this->updateInfo["version"]);
|
||||
$logger->warning("----- PocketMine-MP Auto Updater -----");
|
||||
$logger->warning("Your version of PocketMine-MP is out of date. Version " . $newVersion->get(false) . " (build #" . $newVersion->getBuild() . ") was released on " . date("D M j h:i:s Y", $this->updateInfo["date"]));
|
||||
|
||||
$messages = [
|
||||
"Your version of " . $this->server->getName() . " is out of date. Version " . $newVersion->get(false) . " (build #" . $newVersion->getBuild() . ") was released on " . date("D M j h:i:s Y", $this->updateInfo["date"])
|
||||
];
|
||||
if($this->updateInfo["details_url"] !== null){
|
||||
$logger->warning("Details: " . $this->updateInfo["details_url"]);
|
||||
$messages[] = "Details: " . $this->updateInfo["details_url"];
|
||||
}
|
||||
$logger->warning("Download: " . $this->updateInfo["download_url"]);
|
||||
$logger->warning("----- -------------------------- -----");
|
||||
$messages[] = "Download: " . $this->updateInfo["download_url"];
|
||||
|
||||
$this->printConsoleMessage($messages, \LogLevel::WARNING);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,24 +107,33 @@ class AutoUpdater{
|
||||
* @param Player $player
|
||||
*/
|
||||
public function showPlayerUpdate(Player $player){
|
||||
$player->sendMessage(TextFormat::DARK_PURPLE . "The version of PocketMine-MP that this server is running is out of date. Please consider updating to the latest version.");
|
||||
$player->sendMessage(TextFormat::DARK_PURPLE . "The version of " . $this->server->getName() . " that this server is running is out of date. Please consider updating to the latest version.");
|
||||
$player->sendMessage(TextFormat::DARK_PURPLE . "Check the console for more details.");
|
||||
}
|
||||
|
||||
protected function showChannelSuggestionStable(){
|
||||
$logger = $this->server->getLogger();
|
||||
$logger->info("----- PocketMine-MP Auto Updater -----");
|
||||
$logger->info("It appears you're running a Stable build, when you've specified that you prefer to run " . ucfirst($this->getChannel()) . " builds.");
|
||||
$logger->info("If you would like to be kept informed about new Stable builds only, it is recommended that you change 'preferred-channel' in your pocketmine.yml to 'stable'.");
|
||||
$logger->info("----- -------------------------- -----");
|
||||
$this->printConsoleMessage([
|
||||
"It appears you're running a Stable build, when you've specified that you prefer to run " . ucfirst($this->getChannel()) . " builds.",
|
||||
"If you would like to be kept informed about new Stable builds only, it is recommended that you change 'preferred-channel' in your pocketmine.yml to 'stable'."
|
||||
]);
|
||||
}
|
||||
|
||||
protected function showChannelSuggestionBeta(){
|
||||
$this->printConsoleMessage([
|
||||
"It appears you're running a Beta build, when you've specified that you prefer to run Stable builds.",
|
||||
"If you would like to be kept informed about new Beta or Development builds, it is recommended that you change 'preferred-channel' in your pocketmine.yml to 'beta' or 'development'."
|
||||
]);
|
||||
}
|
||||
|
||||
protected function printConsoleMessage(array $lines, string $logLevel = \LogLevel::INFO){
|
||||
$logger = $this->server->getLogger();
|
||||
$logger->info("----- PocketMine-MP Auto Updater -----");
|
||||
$logger->info("It appears you're running a Beta build, when you've specified that you prefer to run Stable builds.");
|
||||
$logger->info("If you would like to be kept informed about new Beta or Development builds, it is recommended that you change 'preferred-channel' in your pocketmine.yml to 'beta' or 'development'.");
|
||||
$logger->info("----- -------------------------- -----");
|
||||
|
||||
$title = $this->server->getName() . ' Auto Updater';
|
||||
$logger->log($logLevel, sprintf('----- %s -----', $title));
|
||||
foreach($lines as $line){
|
||||
$logger->log($logLevel, $line);
|
||||
}
|
||||
$logger->log($logLevel, sprintf('----- %s -----', str_repeat('-', strlen($title))));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user