From 0e2b7e67ace24457dabe3457ce54e6a19dfddab8 Mon Sep 17 00:00:00 2001 From: Gfortes <59264654+Gfortes985@users.noreply.github.com> Date: Mon, 12 Jan 2026 21:48:21 +0300 Subject: [PATCH 1/5] Update api.php --- routes/api.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/routes/api.php b/routes/api.php index 242165a..3588f7e 100644 --- a/routes/api.php +++ b/routes/api.php @@ -17,3 +17,6 @@ Route::get('/capes/{user}', [ApiController::class, 'cape']); Route::post('/capes', [ApiController::class, 'updateCape'])->name('capes.update'); Route::delete('/capes', [ApiController::class, 'deleteCape'])->name('capes.delete'); + +// Json Provider +Route::get('/textures/{username}', [TextureJsonController::class, 'handle']); From a832f0bf2e12405e580293f603093a3aab0984c4 Mon Sep 17 00:00:00 2001 From: Gfortes <59264654+Gfortes985@users.noreply.github.com> Date: Mon, 12 Jan 2026 21:48:39 +0300 Subject: [PATCH 2/5] Update api.php --- routes/api.php | 1 + 1 file changed, 1 insertion(+) diff --git a/routes/api.php b/routes/api.php index 3588f7e..205afd0 100644 --- a/routes/api.php +++ b/routes/api.php @@ -1,6 +1,7 @@ Date: Mon, 12 Jan 2026 21:49:41 +0300 Subject: [PATCH 3/5] Create TextureJsonController.php --- src/Controllers/TextureJsonController.php | 72 +++++++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/Controllers/TextureJsonController.php diff --git a/src/Controllers/TextureJsonController.php b/src/Controllers/TextureJsonController.php new file mode 100644 index 0000000..d8808ff --- /dev/null +++ b/src/Controllers/TextureJsonController.php @@ -0,0 +1,72 @@ +first(); + + $result = []; + $userId = $user ? $user->id : null; + + //SKIN + if ($userId && Storage::disk('public')->exists("skins/{$userId}.png")) { + $skinFile = "skins/{$userId}.png"; + } elseif (Storage::disk('public')->exists("skins/default.png")) { + $skinFile = "skins/default.png"; + } else { + $skinFile = null; + } + + if ($skinFile) { + $skinPath = Storage::disk('public')->path($skinFile); + + $result['SKIN'] = [ + 'url' => url("/api/skin-api/skins/$username"), + 'digest' => hash_file('sha256', $skinPath), + 'metadata' => [ + 'model' => $this->detectModel($skinPath) + ] + ]; + } + + //CAPE + if ($userId && Storage::disk('public')->exists("capes/{$userId}.png")) { + $capeFile = "capes/{$userId}.png"; + } elseif (Storage::disk('public')->exists("capes/default.png")) { + $capeFile = "capes/default.png"; + } else { + $capeFile = null; + } + + if ($capeFile) { + $capePath = Storage::disk('public')->path($capeFile); + + $result['CAPE'] = [ + 'url' => url("/api/skin-api/capes/$username"), + 'digest' => hash_file('sha256', $capePath) + ]; + } + + return response()->json($result, 200, [], JSON_UNESCAPED_SLASHES); + } + + private function detectModel(string $path): string + { + $img = imagecreatefrompng($path); + + $rgb = imagecolorat($img,55,20); + $colors = imagecolorsforindex($img, $rgb); + $alpha = $colors["alpha"]; + imagedestroy($img); + + + return $alpha === 127 ? 'slim' : 'default'; + } +} From 803e60974c17e4f84889c521206fdef01b492fb5 Mon Sep 17 00:00:00 2001 From: Gfortes <59264654+Gfortes985@users.noreply.github.com> Date: Mon, 12 Jan 2026 21:52:19 +0300 Subject: [PATCH 4/5] Update README.md --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 31b7fee..00c74ad 100644 --- a/README.md +++ b/README.md @@ -42,3 +42,23 @@ Returns the cape of the given user. | -------------- | --------- | ----------------------- | | `access_token` | string | The user's access token | | `cape` | image/png | The cape file | + +### Json + +**GET** `/api/skin-api/textures/{user_name}` +Return the json like this +``` +{ + "SKIN": { + "url": "http://example.com/skins/Gravita.png", + "digest": "SHA256 HASH (HEX)", + "metadata": { + "model": "slim" + } + }, + "CAPE": { + "url": "http://example.com/cloaks/Gravita.png", + "digest": "SHA256 HASH (HEX)" + } +} +``` From 686291f189b4fa73a88cbf1dc6ea4fd155e98f97 Mon Sep 17 00:00:00 2001 From: Gfortes <59264654+Gfortes985@users.noreply.github.com> Date: Mon, 12 Jan 2026 21:54:10 +0300 Subject: [PATCH 5/5] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 00c74ad..fcac90c 100644 --- a/README.md +++ b/README.md @@ -50,14 +50,14 @@ Return the json like this ``` { "SKIN": { - "url": "http://example.com/skins/Gravita.png", + "url": "http://example.com/api/skin-api/skins/gfortes", "digest": "SHA256 HASH (HEX)", "metadata": { "model": "slim" } }, "CAPE": { - "url": "http://example.com/cloaks/Gravita.png", + "url": "http://example.com/api/skin-api/capes/gfortes", "digest": "SHA256 HASH (HEX)" } }