mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-05 11:27:07 +00:00
QueryInfo->setPlayerList() now accepts string[] instead of Player[] (#5476)
This commit is contained in:
parent
2da9b76452
commit
42db3abf5e
@ -29,6 +29,7 @@ use pocketmine\plugin\Plugin;
|
||||
use pocketmine\Server;
|
||||
use pocketmine\utils\Binary;
|
||||
use pocketmine\utils\Utils;
|
||||
use function array_map;
|
||||
use function chr;
|
||||
use function count;
|
||||
use function str_replace;
|
||||
@ -41,7 +42,7 @@ final class QueryInfo{
|
||||
private bool $listPlugins;
|
||||
/** @var Plugin[] */
|
||||
private array $plugins;
|
||||
/** @var Player[] */
|
||||
/** @var string[] */
|
||||
private array $players;
|
||||
|
||||
private string $gametype;
|
||||
@ -67,7 +68,7 @@ final class QueryInfo{
|
||||
$this->serverName = $server->getMotd();
|
||||
$this->listPlugins = $server->getConfigGroup()->getPropertyBool("settings.query-plugins", true);
|
||||
$this->plugins = $server->getPluginManager()->getPlugins();
|
||||
$this->players = $server->getOnlinePlayers();
|
||||
$this->players = array_map(fn(Player $p) => $p->getName(), $server->getOnlinePlayers());
|
||||
|
||||
$this->gametype = ($server->getGamemode()->equals(GameMode::SURVIVAL()) || $server->getGamemode()->equals(GameMode::ADVENTURE())) ? "SMP" : "CMP";
|
||||
$this->version = $server->getVersion();
|
||||
@ -122,17 +123,17 @@ final class QueryInfo{
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Player[]
|
||||
* @return string[]
|
||||
*/
|
||||
public function getPlayerList() : array{
|
||||
return $this->players;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Player[] $players
|
||||
* @param string[] $players
|
||||
*/
|
||||
public function setPlayerList(array $players) : void{
|
||||
Utils::validateArrayValueType($players, function(Player $_) : void{});
|
||||
Utils::validateArrayValueType($players, function(string $_) : void{});
|
||||
$this->players = $players;
|
||||
$this->destroyCache();
|
||||
}
|
||||
@ -226,7 +227,7 @@ final class QueryInfo{
|
||||
|
||||
$query .= "\x00\x01player_\x00\x00";
|
||||
foreach($this->players as $player){
|
||||
$query .= $player->getName() . "\x00";
|
||||
$query .= $player . "\x00";
|
||||
}
|
||||
$query .= "\x00";
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user