mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Move some configuration constants to .. well .. constants
This commit is contained in:
parent
60938c8c9d
commit
79b5109953
@ -177,6 +177,12 @@ class Server{
|
||||
public const BROADCAST_CHANNEL_ADMINISTRATIVE = "pocketmine.broadcast.admin";
|
||||
public const BROADCAST_CHANNEL_USERS = "pocketmine.broadcast.user";
|
||||
|
||||
public const DEFAULT_SERVER_NAME = VersionInfo::NAME . " Server";
|
||||
public const DEFAULT_MAX_PLAYERS = 20;
|
||||
public const DEFAULT_PORT_IPV4 = 19132;
|
||||
public const DEFAULT_PORT_IPV6 = 19133;
|
||||
public const DEFAULT_VIEW_DISTANCE = 8;
|
||||
|
||||
private static ?Server $instance = null;
|
||||
|
||||
private SleeperHandler $tickSleeper;
|
||||
@ -323,15 +329,15 @@ class Server{
|
||||
}
|
||||
|
||||
public function getPort() : int{
|
||||
return $this->configGroup->getConfigInt("server-port", 19132);
|
||||
return $this->configGroup->getConfigInt("server-port", self::DEFAULT_PORT_IPV4);
|
||||
}
|
||||
|
||||
public function getPortV6() : int{
|
||||
return $this->configGroup->getConfigInt("server-portv6", 19133);
|
||||
return $this->configGroup->getConfigInt("server-portv6", self::DEFAULT_PORT_IPV6);
|
||||
}
|
||||
|
||||
public function getViewDistance() : int{
|
||||
return max(2, $this->configGroup->getConfigInt("view-distance", 8));
|
||||
return max(2, $this->configGroup->getConfigInt("view-distance", self::DEFAULT_VIEW_DISTANCE));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -379,7 +385,7 @@ class Server{
|
||||
}
|
||||
|
||||
public function getMotd() : string{
|
||||
return $this->configGroup->getConfigString("motd", VersionInfo::NAME . " Server");
|
||||
return $this->configGroup->getConfigString("motd", self::DEFAULT_SERVER_NAME);
|
||||
}
|
||||
|
||||
public function getLoader() : \DynamicClassLoader{
|
||||
@ -797,12 +803,12 @@ class Server{
|
||||
$this->configGroup = new ServerConfigGroup(
|
||||
new Config($pocketmineYmlPath, Config::YAML, []),
|
||||
new Config(Path::join($this->dataPath, "server.properties"), Config::PROPERTIES, [
|
||||
"motd" => VersionInfo::NAME . " Server",
|
||||
"server-port" => 19132,
|
||||
"server-portv6" => 19133,
|
||||
"motd" => self::DEFAULT_SERVER_NAME,
|
||||
"server-port" => self::DEFAULT_PORT_IPV4,
|
||||
"server-portv6" => self::DEFAULT_PORT_IPV6,
|
||||
"enable-ipv6" => true,
|
||||
"white-list" => false,
|
||||
"max-players" => 20,
|
||||
"max-players" => self::DEFAULT_MAX_PLAYERS,
|
||||
"gamemode" => GameMode::SURVIVAL()->name(),
|
||||
"force-gamemode" => false,
|
||||
"hardcore" => false,
|
||||
@ -814,7 +820,7 @@ class Server{
|
||||
"level-type" => "DEFAULT",
|
||||
"enable-query" => true,
|
||||
"auto-save" => true,
|
||||
"view-distance" => 8,
|
||||
"view-distance" => self::DEFAULT_VIEW_DISTANCE,
|
||||
"xbox-auth" => true,
|
||||
"language" => "eng"
|
||||
])
|
||||
@ -911,7 +917,7 @@ class Server{
|
||||
$this->banByIP = new BanList($bannedIpsTxt);
|
||||
$this->banByIP->load();
|
||||
|
||||
$this->maxPlayers = $this->configGroup->getConfigInt("max-players", 20);
|
||||
$this->maxPlayers = $this->configGroup->getConfigInt("max-players", self::DEFAULT_MAX_PLAYERS);
|
||||
|
||||
$this->onlineMode = $this->configGroup->getConfigBool("xbox-auth", true);
|
||||
if($this->onlineMode){
|
||||
|
@ -32,6 +32,7 @@ use pocketmine\lang\KnownTranslationFactory;
|
||||
use pocketmine\lang\Language;
|
||||
use pocketmine\lang\LanguageNotFoundException;
|
||||
use pocketmine\player\GameMode;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\Config;
|
||||
use pocketmine\utils\Internet;
|
||||
use pocketmine\utils\InternetException;
|
||||
@ -46,9 +47,9 @@ use const PHP_EOL;
|
||||
use const STDIN;
|
||||
|
||||
class SetupWizard{
|
||||
public const DEFAULT_NAME = VersionInfo::NAME . " Server";
|
||||
public const DEFAULT_PORT = 19132;
|
||||
public const DEFAULT_PLAYERS = 20;
|
||||
public const DEFAULT_NAME = Server::DEFAULT_SERVER_NAME;
|
||||
public const DEFAULT_PORT = Server::DEFAULT_PORT_IPV4;
|
||||
public const DEFAULT_PLAYERS = Server::DEFAULT_MAX_PLAYERS;
|
||||
|
||||
/** @var Language */
|
||||
private $lang;
|
||||
|
Loading…
x
Reference in New Issue
Block a user