mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
Cleaned up ping response and added missing fields (#1114)
This commit is contained in:
parent
d474f73665
commit
409fc282d2
@ -441,6 +441,21 @@ class Server{
|
||||
return "UNKNOWN";
|
||||
}
|
||||
|
||||
public static function getGamemodeName(int $mode) : string{
|
||||
switch($mode){
|
||||
case Player::SURVIVAL:
|
||||
return "Survival";
|
||||
case Player::CREATIVE:
|
||||
return "Creative";
|
||||
case Player::ADVENTURE:
|
||||
return "Adventure";
|
||||
case Player::SPECTATOR:
|
||||
return "Spectator";
|
||||
default:
|
||||
throw new \InvalidArgumentException("Invalid gamemode $mode");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a string and returns a gamemode integer, -1 if not found
|
||||
*
|
||||
|
@ -58,7 +58,7 @@ interface SourceInterface{
|
||||
/**
|
||||
* @param string $name
|
||||
*/
|
||||
public function setName($name);
|
||||
public function setName(string $name);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
|
@ -165,15 +165,21 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
|
||||
|
||||
}
|
||||
|
||||
public function setName($name){
|
||||
public function setName(string $name){
|
||||
$info = $this->server->getQueryInformation();
|
||||
|
||||
$this->interface->sendOption("name",
|
||||
"MCPE;" . rtrim(addcslashes($name, ";"), '\\') . ";" .
|
||||
ProtocolInfo::CURRENT_PROTOCOL . ";" .
|
||||
ProtocolInfo::MINECRAFT_VERSION_NETWORK . ";" .
|
||||
$info->getPlayerCount() . ";" .
|
||||
$info->getMaxPlayerCount()
|
||||
$this->interface->sendOption("name", implode(";",
|
||||
[
|
||||
"MCPE",
|
||||
rtrim(addcslashes($name, ";"), '\\'),
|
||||
ProtocolInfo::CURRENT_PROTOCOL,
|
||||
ProtocolInfo::MINECRAFT_VERSION_NETWORK,
|
||||
$info->getPlayerCount(),
|
||||
$info->getMaxPlayerCount(),
|
||||
"-1",
|
||||
$this->server->getName(),
|
||||
Server::getGamemodeName($this->server->getGamemode())
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user