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