Generate and use constants for pocketmine.yml constant names

a couple of usages of properties that no longer exist couldn't be migrated.
in addition, this revealed a couple of dead properties in the default file.

this is not an ideal solution (I'd much rather model the configs using classes and map them) but in the absence of a good and reliable library to do that, this is the next best thing.
This commit is contained in:
Dylan K. Taylor
2023-08-25 13:23:38 +01:00
parent 506d8d1064
commit 31d8cc1cb5
14 changed files with 258 additions and 61 deletions

View File

@ -27,6 +27,7 @@ use pocketmine\event\server\UpdateNotifyEvent;
use pocketmine\Server;
use pocketmine\utils\VersionString;
use pocketmine\VersionInfo;
use pocketmine\YmlServerProperties;
use function date;
use function strtolower;
use function ucfirst;
@ -43,7 +44,7 @@ class UpdateChecker{
$this->logger = new \PrefixedLogger($server->getLogger(), "Update Checker");
$this->endpoint = "http://$endpoint/api/";
if($server->getConfigGroup()->getPropertyBool("auto-updater.enabled", true)){
if($server->getConfigGroup()->getPropertyBool(YmlServerProperties::AUTO_UPDATER_ENABLED, true)){
$this->doCheck();
}
}
@ -59,7 +60,7 @@ class UpdateChecker{
$this->checkUpdate($updateInfo);
if($this->hasUpdate()){
(new UpdateNotifyEvent($this))->call();
if($this->server->getConfigGroup()->getPropertyBool("auto-updater.on-update.warn-console", true)){
if($this->server->getConfigGroup()->getPropertyBool(YmlServerProperties::AUTO_UPDATER_ON_UPDATE_WARN_CONSOLE, true)){
$this->showConsoleUpdate();
}
}else{
@ -157,7 +158,7 @@ class UpdateChecker{
* Returns the channel used for update checking (stable, beta, dev)
*/
public function getChannel() : string{
return strtolower($this->server->getConfigGroup()->getPropertyString("auto-updater.preferred-channel", "stable"));
return strtolower($this->server->getConfigGroup()->getPropertyString(YmlServerProperties::AUTO_UPDATER_PREFERRED_CHANNEL, "stable"));
}
/**