Added more output types for the uuid endpoint.
This commit is contained in:
parent
e31c17dba2
commit
3fde4fab90
1 changed files with 12 additions and 3 deletions
|
@ -36,7 +36,7 @@ final class MojangInterop {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function registerRoutes(IRouter $router): void {
|
public static function registerRoutes(IRouter $router): void {
|
||||||
$router->get('/uuid', fn($response, $request) => self::uuidResolver($request));
|
$router->get('/uuid', fn($response, $request) => self::uuidResolver($response, $request));
|
||||||
$router->get('/blockedservers', fn($response, $request) => self::proxyBlockServers($response, $request));
|
$router->get('/blockedservers', fn($response, $request) => self::proxyBlockServers($response, $request));
|
||||||
|
|
||||||
// figure out how to proxy these someday to keep online mode working transparently
|
// figure out how to proxy these someday to keep online mode working transparently
|
||||||
|
@ -44,8 +44,17 @@ final class MojangInterop {
|
||||||
$router->post('/session/minecraft/join', fn() => 501);
|
$router->post('/session/minecraft/join', fn() => 501);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function uuidResolver(HttpRequest $request): string {
|
public static function uuidResolver(HttpResponseBuilder $response, HttpRequest $request): string {
|
||||||
return (string)self::createOfflinePlayerUUID((string)$request->getParam('name'))->getHex();
|
$response->setTypePlain();
|
||||||
|
$uuid = self::createOfflinePlayerUUID((string)$request->getParam('name'));
|
||||||
|
|
||||||
|
return (string)match((string)$request->getParam('mode')) {
|
||||||
|
'str' => $uuid->toString(),
|
||||||
|
'urn' => $uuid->getUrn(),
|
||||||
|
'raw' => $uuid->getBytes(),
|
||||||
|
'int' => $uuid->getInteger(),
|
||||||
|
default => $uuid->getHex(),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getRequest(string $url, string $userAgent): object {
|
public static function getRequest(string $url, string $userAgent): object {
|
||||||
|
|
Loading…
Reference in a new issue