mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-27 06:29:19 +08:00
fix cache of requests with size
This commit is contained in:
parent
2b55346a0c
commit
31001f15ae
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Events\Event;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Events\Event;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\Player;
|
||||
use App\Events\Event;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Events\Event;
|
||||
use App\Models\Texture;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use App\Events\Event;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
||||
|
@ -3,7 +3,6 @@
|
||||
namespace App\Events;
|
||||
|
||||
use App\Models\PlayerModel;
|
||||
use App\Events\Event;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
|
||||
|
||||
|
@ -19,15 +19,16 @@ class CacheAvatarPreview
|
||||
{
|
||||
$tid = $event->texture->tid;
|
||||
$hash = $event->texture->hash;
|
||||
$size = $event->size;
|
||||
|
||||
$path = BASE_DIR."/storage/textures/$hash";
|
||||
|
||||
if (!\Storage::disk('cache')->has("avatar/$tid")) {
|
||||
if (!\Storage::disk('cache')->has("avatar/$tid-$size")) {
|
||||
$png = \Minecraft::generateAvatarFromSkin($path, $event->size);
|
||||
imagepng($png, BASE_DIR."/storage/cache/avatar/$tid");
|
||||
imagepng($png, BASE_DIR."/storage/cache/avatar/$tid-$size");
|
||||
imagedestroy($png);
|
||||
}
|
||||
|
||||
return \Response::png(\Storage::disk('cache')->get("avatar/$tid"));
|
||||
return \Response::png(\Storage::disk('cache')->get("avatar/$tid-$size"));
|
||||
}
|
||||
}
|
||||
|
@ -17,22 +17,23 @@ class CacheSkinPreview
|
||||
*/
|
||||
public function handle(GetSkinPreview $event)
|
||||
{
|
||||
$tid = $event->texture->tid;
|
||||
$tid = $event->texture->tid;
|
||||
$size = $event->size;
|
||||
|
||||
if (!Storage::disk('cache')->has("preview/$tid")) {
|
||||
if (!Storage::disk('cache')->has("preview/$tid-$size")) {
|
||||
$filename = BASE_DIR."/storage/textures/{$event->texture->hash}";
|
||||
|
||||
if ($event->texture->type == "cape") {
|
||||
$png = \Minecraft::generatePreviewFromCape($filename, $event->size);
|
||||
imagepng($png, BASE_DIR."/storage/cache/preview/$tid");
|
||||
imagepng($png, BASE_DIR."/storage/cache/preview/$tid-$size");
|
||||
imagedestroy($png);
|
||||
} else {
|
||||
$png = \Minecraft::generatePreviewFromSkin($filename, $event->size);
|
||||
imagepng($png, BASE_DIR."/storage/cache/preview/$tid");
|
||||
imagepng($png, BASE_DIR."/storage/cache/preview/$tid-$size");
|
||||
imagedestroy($png);
|
||||
}
|
||||
}
|
||||
|
||||
return \Response::png(Storage::disk('cache')->get("preview/$tid"));
|
||||
return \Response::png(Storage::disk('cache')->get("preview/$tid-$size"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user