Updated Minecraft website code with new endpoints and new mod jar.

This commit is contained in:
flash 2024-07-12 15:31:06 +00:00
parent 8880303543
commit a508190185
5 changed files with 70 additions and 35 deletions

Binary file not shown.

View file

@ -36,10 +36,6 @@ 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($response, $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
$router->get('/session/minecraft/hasJoined', fn() => 501);
$router->post('/session/minecraft/join', fn() => 501);
} }
public static function uuidResolver(HttpResponseBuilder $response, HttpRequest $request): string { public static function uuidResolver(HttpResponseBuilder $response, HttpRequest $request): string {
@ -132,16 +128,19 @@ final class MojangInterop {
return json_decode($info->body); 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')); $info = self::getSessionMinecraftProfileRaw($uuid, $request->getHeaderLine('User-Agent'));
$response->setStatusCode((int)$info->status[1]);
$response->setCacheControl('max-age=30');
foreach($info->headers as $header) { if($response !== null) {
[$name, $value] = explode(':', $header); $response->setStatusCode((int)$info->status[1]);
$name = strtolower(trim($name)); $response->setCacheControl('max-age=30');
if(str_starts_with($name, 'x-') || $name === 'content-type')
$response->setHeader($name, $value); 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; return $info->body;

View file

@ -9,7 +9,7 @@ use RuntimeException;
use Index\XString; use Index\XString;
use Index\Http\Routing\{RouteHandler,HttpGet,HttpMiddleware,HttpPost}; use Index\Http\Routing\{RouteHandler,HttpGet,HttpMiddleware,HttpPost};
use Index\Security\CSRFP; use Index\Security\CSRFP;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\{Uuid,UuidInterface};
use Sasae\SasaeEnvironment; use Sasae\SasaeEnvironment;
class SkinsRoutes extends RouteHandler { class SkinsRoutes extends RouteHandler {
@ -326,22 +326,7 @@ class SkinsRoutes extends RouteHandler {
$response->redirect('/skins'); $response->redirect('/skins');
} }
#[HttpGet('/session/minecraft/profile/([a-fA-F0-9\-]+)')] private function getProfileInfo(UuidInterface $uuid, bool $includeProfileActions) {
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');
if(!MojangInterop::isOfflineId($uuid)) if(!MojangInterop::isOfflineId($uuid))
return 204; return 204;
@ -368,10 +353,9 @@ class SkinsRoutes extends RouteHandler {
$profileId = (string)$uuid->getHex(); $profileId = (string)$uuid->getHex();
$profileName = $linkInfo->getName(); $profileName = $linkInfo->getName();
return [ $profileInfo = [
'id' => $profileId, 'id' => $profileId,
'name' => $profileName, 'name' => $profileName,
'profileActions' => [],
'properties' => [ 'properties' => [
[ [
'name' => 'textures', '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_]+)')] #[HttpGet('/users/profiles/minecraft/([A-Za-z0-9_]+)')]

View file

@ -13,7 +13,8 @@
<p>This as a mod built on <a href="https://fabricmc.net/" target="_blank" rel="noopener">Fabric</a> 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.</p> <p>This as a mod built on <a href="https://fabricmc.net/" target="_blank" rel="noopener">Fabric</a> 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.</p>
<ul> <ul>
<li><a href="/dl/flashii-extensions-1.0.0.jar" download>Download Flashii Extensions 1.0.0</a></li> <li><strong><a href="/dl/flashii-extensions-1.1.0.jar" download>Download Flashii Extensions 1.1.0 for Minecraft 1.21</a></strong></li>
<li><a href="/dl/flashii-extensions-1.0.0.jar" download>Download Flashii Extensions 1.0.0 for Minecraft 1.20.1</a></li>
<li><a href="https://patchii.net/flashii/mcexts" target="_blank" rel="noopener">Source Code</a></li> <li><a href="https://patchii.net/flashii/mcexts" target="_blank" rel="noopener">Source Code</a></li>
</ul> </ul>
</div> </div>

View file

@ -6,6 +6,7 @@
<div class="section" id="start"> <div class="section" id="start">
<h1><a href="#start">Guide to getting you started</a></h1> <h1><a href="#start">Guide to getting you started</a></h1>
<p>This guide will walk you through the steps of settings up a client and connecting to one of our servers.</p> <p>This guide will walk you through the steps of settings up a client and connecting to one of our servers.</p>
<p><strong>IMPORTANT:</strong> 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.</p>
</div> </div>
<div class="section" id="gac"> <div class="section" id="gac">
@ -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. 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. 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.
</p> </p>
<p><a href="https://adoptium.net/temurin/releases/?version=17&os=windows&package=jre" target="_blank" rel="noopener">Go to the Adoptium Website</a></p> <p><a href="https://adoptium.net/temurin/releases/?version=21&os=windows&package=jre" target="_blank" rel="noopener">Go to the Adoptium Website</a></p>
<p> <p>
Click on the ".msi" button for whichever architecture is applicable to you (likely x64) and install it. Click on the ".msi" button for whichever architecture is applicable to you (likely x64) and install it.
<em>Make sure the installer is set to install <strong>Set JAVA_HOME variable</strong> and <strong>JavaSoft (Oracle) registry keys</strong> or you will have issues later on.</em> <em>Make sure the installer is set to install <strong>Set JAVA_HOME variable</strong> and <strong>JavaSoft (Oracle) registry keys</strong> or you will have issues later on.</em>
@ -46,8 +47,8 @@
<p> <p>
The first time you start it you'll be asked to pick a language and what version of Java to use. 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 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 <code>javaw.exe</code> should be something among the lines of <code>C:/Program Files/Eclipse Adoptium/jdk-17.0.8.7-hotspot/bin/javaw.exe</code>. If you did not properly follow the previous step, the path of the <code>javaw.exe</code> should be something among the lines of <code>C:/Program Files/Eclipse Adoptium/jdk-21.0.2.13-hotspot/bin/javaw.exe</code>.
During the next step of the Quick Setup, make sure to select <strong>Background Cat (from MultiMC)</strong> because he's epic. During the next step of the Quick Setup, make sure to select <strong>Background Cat (from MultiMC)</strong> because they are epic.
</p> </p>
<p>You should now be at the main screen of Prism Launcher!</p> <p>You should now be at the main screen of Prism Launcher!</p>
</div> </div>