diff --git a/public/dl/flashii-extensions-1.1.0.jar b/public/dl/flashii-extensions-1.1.0.jar new file mode 100644 index 0000000..0be8c38 Binary files /dev/null and b/public/dl/flashii-extensions-1.1.0.jar differ diff --git a/src/MojangInterop.php b/src/MojangInterop.php index 153551e..64cdb6c 100644 --- a/src/MojangInterop.php +++ b/src/MojangInterop.php @@ -36,10 +36,6 @@ final class MojangInterop { public static function registerRoutes(IRouter $router): void { $router->get('/uuid', fn($response, $request) => self::uuidResolver($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 - $router->get('/session/minecraft/hasJoined', fn() => 501); - $router->post('/session/minecraft/join', fn() => 501); } public static function uuidResolver(HttpResponseBuilder $response, HttpRequest $request): string { @@ -132,16 +128,19 @@ final class MojangInterop { return json_decode($info->body); } - public static function proxySessionMinecraftProfile(HttpResponseBuilder $response, HttpRequest $request, string $uuid): string { + public static function proxySessionMinecraftProfile(?HttpResponseBuilder $response, HttpRequest $request, string $uuid): string { $info = self::getSessionMinecraftProfileRaw($uuid, $request->getHeaderLine('User-Agent')); - $response->setStatusCode((int)$info->status[1]); - $response->setCacheControl('max-age=30'); - foreach($info->headers as $header) { - [$name, $value] = explode(':', $header); - $name = strtolower(trim($name)); - if(str_starts_with($name, 'x-') || $name === 'content-type') - $response->setHeader($name, $value); + if($response !== null) { + $response->setStatusCode((int)$info->status[1]); + $response->setCacheControl('max-age=30'); + + foreach($info->headers as $header) { + [$name, $value] = explode(':', $header); + $name = strtolower(trim($name)); + if(str_starts_with($name, 'x-') || $name === 'content-type') + $response->setHeader($name, $value); + } } return $info->body; diff --git a/src/SkinsRoutes.php b/src/SkinsRoutes.php index d8b2bbc..2c2f2a6 100644 --- a/src/SkinsRoutes.php +++ b/src/SkinsRoutes.php @@ -9,7 +9,7 @@ use RuntimeException; use Index\XString; use Index\Http\Routing\{RouteHandler,HttpGet,HttpMiddleware,HttpPost}; use Index\Security\CSRFP; -use Ramsey\Uuid\Uuid; +use Ramsey\Uuid\{Uuid,UuidInterface}; use Sasae\SasaeEnvironment; class SkinsRoutes extends RouteHandler { @@ -326,22 +326,7 @@ class SkinsRoutes extends RouteHandler { $response->redirect('/skins'); } - #[HttpGet('/session/minecraft/profile/([a-fA-F0-9\-]+)')] - public function getSessionMinecraftProfile($response, $request, string $id) { - try { - $uuid = Uuid::fromString($id); - } catch(InvalidArgumentException $ex) { - $response->setStatusCode(400); - return [ - 'path' => sprintf('/session/minecraft/profile/%s', $id), - 'errorMessage' => sprintf('Not a valid UUID: %s', $id), - ]; - } - - if(MojangInterop::isMojangId($uuid)) - return MojangInterop::proxySessionMinecraftProfile($response, $request, $id); - - $response->setCacheControl('max-age=30'); + private function getProfileInfo(UuidInterface $uuid, bool $includeProfileActions) { if(!MojangInterop::isOfflineId($uuid)) return 204; @@ -368,10 +353,9 @@ class SkinsRoutes extends RouteHandler { $profileId = (string)$uuid->getHex(); $profileName = $linkInfo->getName(); - return [ + $profileInfo = [ 'id' => $profileId, 'name' => $profileName, - 'profileActions' => [], 'properties' => [ [ 'name' => 'textures', @@ -384,6 +368,56 @@ class SkinsRoutes extends RouteHandler { ], ], ]; + + if($includeProfileActions) + $profileInfo['profileActions'] = []; + + return $profileInfo; + } + + #[HttpGet('/session/minecraft/profile/([a-fA-F0-9\-]+)')] + public function getSessionMinecraftProfile($response, $request, string $id) { + try { + $uuid = Uuid::fromString($id); + } catch(InvalidArgumentException $ex) { + $response->setStatusCode(400); + return [ + 'path' => sprintf('/session/minecraft/profile/%s', $id), + 'errorMessage' => sprintf('Not a valid UUID: %s', $id), + ]; + } + + if(MojangInterop::isMojangId($uuid)) { + $raw = MojangInterop::proxySessionMinecraftProfile(null, $request, $id); + $result = json_decode($raw); + if(!is_object($result)) + return $raw; + + $uuid = MojangInterop::createOfflinePlayerUUID($result->name); + } + + $response->setCacheControl('max-age=30'); + + return $this->getProfileInfo($uuid, true); + } + + #[HttpPost('/session/minecraft/join')] + public function postSessionMinecraftJoin($response, $request) { + if(!$request->isJsonContent()) + return 415; + + // just accept this always idk if it matters + return 204; + } + + #[HttpGet('/session/minecraft/hasJoined')] + public function getSessionMinecraftHasJoined($response, $request) { + $userName = (string)$request->getParam('username'); + $serverId = (string)$request->getParam('serverId'); + $remoteAddr = (string)$request->getParam('ip'); + $uuid = MojangInterop::createOfflinePlayerUUID($userName); + + return $this->getProfileInfo($uuid, false); } #[HttpGet('/users/profiles/minecraft/([A-Za-z0-9_]+)')] diff --git a/templates/downloads.twig b/templates/downloads.twig index e10b686..cc3d14c 100644 --- a/templates/downloads.twig +++ b/templates/downloads.twig @@ -13,7 +13,8 @@

This as a mod built on Fabric to alter the server your Minecraft client uses to request skins from Mojang's to ours. This mod is likely why you're on this page.

diff --git a/templates/guide.twig b/templates/guide.twig index 4fac96f..160c922 100644 --- a/templates/guide.twig +++ b/templates/guide.twig @@ -6,6 +6,7 @@

Guide to getting you started

This guide will walk you through the steps of settings up a client and connecting to one of our servers.

+

IMPORTANT: I will not be updating this guide for every new version of things that come out, unless the process changes drastically. Prism Launcher does a good job of telling you what version of Fabric is good for your selected version of Minecraft using the little star icon.

@@ -23,7 +24,7 @@ For some reason Oracle doesn't make their own new versions of Java and restrictive licences likely prevent Mojang and Prism from distributing their own, so we're going to have to download one ourselves. This part may only apply to Windows, I'm not sure how it would go on macOS and I can't be bothered to test on Linux distributions so you might have to improvise for this step.

-

Go to the Adoptium Website

+

Go to the Adoptium Website

Click on the ".msi" button for whichever architecture is applicable to you (likely x64) and install it. Make sure the installer is set to install Set JAVA_HOME variable and JavaSoft (Oracle) registry keys or you will have issues later on. @@ -46,8 +47,8 @@

The first time you start it you'll be asked to pick a language and what version of Java to use. If you properly followed the previous step the Adoptium JVM should be immediately selected. - If you did not properly follow the previous step, the path of the javaw.exe should be something among the lines of C:/Program Files/Eclipse Adoptium/jdk-17.0.8.7-hotspot/bin/javaw.exe. - During the next step of the Quick Setup, make sure to select Background Cat (from MultiMC) because he's epic. + If you did not properly follow the previous step, the path of the javaw.exe should be something among the lines of C:/Program Files/Eclipse Adoptium/jdk-21.0.2.13-hotspot/bin/javaw.exe. + During the next step of the Quick Setup, make sure to select Background Cat (from MultiMC) because they are epic.

You should now be at the main screen of Prism Launcher!