Updated to Laravel 9, small fixes, and more
This commit is contained in:
parent
6fc52ee512
commit
9fd844ae1a
24 changed files with 5589 additions and 2557 deletions
|
@ -1,101 +1,101 @@
|
|||
<?php
|
||||
|
||||
namespace App\Cache;
|
||||
|
||||
class Cache {
|
||||
class Cache
|
||||
{
|
||||
|
||||
public static function getUsername($uuid) {
|
||||
if(file_exists(storage_path('app/uuid/'.$uuid.'.json'))) {
|
||||
$json = file_get_contents(storage_path('app/uuid/'.$uuid.'.json'));
|
||||
public static function getUsername($uuid)
|
||||
{
|
||||
if (file_exists(storage_path('app/uuid/' . $uuid . '.json'))) {
|
||||
$json = file_get_contents(storage_path('app/uuid/' . $uuid . '.json'));
|
||||
$json = json_decode($json, true);
|
||||
if((time() - strtotime($json['time'])) > 3600) {
|
||||
$json = file_get_contents('https://api.mojang.com/user/profiles/'.$uuid.'/names');
|
||||
if(empty($json)) {
|
||||
$json = file_get_contents(storage_path('app/uuid/'.$uuid.'.json'));
|
||||
if ((time() - strtotime($json['time'])) > 3600) {
|
||||
$json = file_get_contents('https://api.mojang.com/user/profile/' . $uuid);
|
||||
if (empty($json)) {
|
||||
$json = file_get_contents(storage_path('app/uuid/' . $uuid . '.json'));
|
||||
$json = json_decode($json, true);
|
||||
return $json['name'];
|
||||
}
|
||||
|
||||
$json = json_decode($json, true);
|
||||
if(isset($json['error'])) {
|
||||
$json = file_get_contents(storage_path('app/uuid/'.$uuid.'.json'));
|
||||
if (isset($json['error'])) {
|
||||
$json = file_get_contents(storage_path('app/uuid/' . $uuid . '.json'));
|
||||
$json = json_decode($json, true);
|
||||
return $json['name'];
|
||||
}
|
||||
|
||||
$name = $json[count($json) -1]['name'];
|
||||
$name = $json['name'];
|
||||
$json = [];
|
||||
$json['id'] = $uuid;
|
||||
$json['name'] = $name;
|
||||
self::saveJson($json);
|
||||
return $json['name'];
|
||||
} else {
|
||||
return $json['name'];
|
||||
}
|
||||
} else {
|
||||
$json = file_get_contents('https://api.mojang.com/user/profiles/'.$uuid.'/names');
|
||||
if(empty($json))
|
||||
$json = file_get_contents('https://api.mojang.com/user/profile/' . $uuid);
|
||||
if (empty($json))
|
||||
return $uuid;
|
||||
|
||||
$json = json_decode($json, true);
|
||||
if(isset($json['error']))
|
||||
if (isset($json['error']))
|
||||
return $uuid;
|
||||
|
||||
$name = $json[count($json) -1]['name'];
|
||||
$name = $json['name'];
|
||||
$json = [];
|
||||
$json['id'] = $uuid;
|
||||
$json['name'] = $name;
|
||||
self::saveJson($json);
|
||||
return $json['name'];
|
||||
}
|
||||
return $json['name'];
|
||||
}
|
||||
|
||||
public static function getUUID($username) {
|
||||
foreach(glob(storage_path('app/uuid/*')) as $file) {
|
||||
public static function getUUID($username)
|
||||
{
|
||||
foreach (glob(storage_path('app/uuid/*')) as $file) {
|
||||
$json = file_get_contents($file);
|
||||
$json = json_decode($json, true);
|
||||
if($json['name'] !== $username)
|
||||
if ($json['name'] !== $username)
|
||||
continue;
|
||||
|
||||
if((time() - strtotime($json['time'])) > 3600) {
|
||||
$json = file_get_contents('https://api.mojang.com/users/profiles/minecraft/'.$username);
|
||||
if(empty($json)) {
|
||||
unlink(storage_path('app/uuid/'.$file));
|
||||
if ((time() - strtotime($json['time'])) > 3600) {
|
||||
$json = file_get_contents('https://api.mojang.com/users/profiles/minecraft/' . $username);
|
||||
if (empty($json)) {
|
||||
unlink(storage_path('app/uuid/' . $file));
|
||||
return $username;
|
||||
}
|
||||
|
||||
$json = json_decode($json, true);
|
||||
if(isset($json['error'])) {
|
||||
unlink(storage_path('app/uuid/'.$file));
|
||||
if (isset($json['error'])) {
|
||||
unlink(storage_path('app/uuid/' . $file));
|
||||
return $username;
|
||||
}
|
||||
|
||||
self::saveJson($json);
|
||||
return $json['id'];
|
||||
} else {
|
||||
return $json['id'];
|
||||
}
|
||||
return $json['id'];
|
||||
}
|
||||
|
||||
$json = file_get_contents('https://api.mojang.com/users/profiles/minecraft/'.$username);
|
||||
if(empty($json))
|
||||
$json = file_get_contents('https://api.mojang.com/users/profiles/minecraft/' . $username);
|
||||
if (empty($json))
|
||||
return $username;
|
||||
|
||||
$json = json_decode($json, true);
|
||||
if(isset($json['error']))
|
||||
if (isset($json['error']))
|
||||
return $username;
|
||||
|
||||
self::saveJson($json);
|
||||
return $json['id'];
|
||||
}
|
||||
|
||||
public static function saveJson($json) {
|
||||
public static function saveJson($json)
|
||||
{
|
||||
$array = [
|
||||
'id' => $json['id'],
|
||||
'name' => $json['name'],
|
||||
'time' => date('d-m-Y H:m:s')
|
||||
];
|
||||
|
||||
file_put_contents(storage_path('app/uuid/'.$json['id'].'.json'), json_encode($array));
|
||||
file_put_contents(storage_path('app/uuid/' . $json['id'] . '.json'), json_encode($array));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue