Clean up
This commit is contained in:
parent
611f6c8cee
commit
e97d2743fb
@ -137,7 +137,7 @@ class TextureController extends Controller
|
||||
$player = Player::where('name', $name)->first();
|
||||
abort_unless($player, 404);
|
||||
|
||||
$hash = $player->getTexture('skin');
|
||||
$hash = optional($player->skin)->hash;
|
||||
if (Storage::disk('textures')->has($hash)) {
|
||||
$png = Minecraft::generateAvatarFromSkin(
|
||||
Storage::disk('textures')->read($hash),
|
||||
|
@ -73,20 +73,4 @@ class Player extends Model
|
||||
|
||||
return json_encode($profile, $options | JSON_UNESCAPED_UNICODE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get specific texture of player.
|
||||
*
|
||||
* @param string $type "skin" or "cape"
|
||||
*
|
||||
* @return string the sha256 hash of texture file
|
||||
*/
|
||||
public function getTexture($type)
|
||||
{
|
||||
if (in_array($type, self::$types)) {
|
||||
return Arr::get(Texture::find($this["tid_$type"]), 'hash');
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -10,17 +10,6 @@ class PlayerTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
public function testGetTexture()
|
||||
{
|
||||
$skin = factory(Texture::class)->create();
|
||||
$player = factory(Player::class)->create(['tid_skin' => $skin->tid]);
|
||||
|
||||
$player = Player::find($player->pid);
|
||||
$this->assertEquals($skin->hash, $player->getTexture('skin'));
|
||||
|
||||
$this->assertFalse($player->getTexture('invalid_type'));
|
||||
}
|
||||
|
||||
public function testGetModelAttribute()
|
||||
{
|
||||
$player = factory(Player::class)->create();
|
||||
|
Loading…
Reference in New Issue
Block a user