From ef5535cb39da5cff06c8fcb7df7c3405e82d9ae0 Mon Sep 17 00:00:00 2001 From: flashwave Date: Wed, 21 Feb 2024 16:32:21 +0000 Subject: [PATCH] Added skin route for Minecraft Beta 1.7.3. --- src/SkinsRoutes.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/SkinsRoutes.php b/src/SkinsRoutes.php index baa186d..bf7b988 100644 --- a/src/SkinsRoutes.php +++ b/src/SkinsRoutes.php @@ -403,4 +403,27 @@ class SkinsRoutes extends RouteHandler { 'name' => $linkInfo->getName(), ]; } + + // quirky path and two of them to achieve equal string length with http://s3.amazonaws.com/MinecraftSkins/ for flashii.net and edgii.net + #[Route('GET', '/s3MinecraftSkins/:filename')] + #[Route('GET', '/s3s3MinecraftSkins/:filename')] + public function getS3MinecraftSkin($response, $request, string $name) { + $path = pathinfo($name); + if(empty($path) || empty($path['filename']) || empty($path['extension']) || $path['extension'] !== 'png') + return 404; + + try { + $linkInfo = $this->accountLinks->getLink(name: $path['filename']); + } catch(RuntimeException $ex) { + return 404; + } + + $skinInfo = $this->skins->getSkin($linkInfo); + if($skinInfo === null) + return 404; + + $response->accelRedirect($this->getRemotePath($skinInfo->getHash(), false)); + $response->setContentType('image/png'); + $response->setFileName("{$path['filename']}.{$path['extension']}", false); + } }