removed uuid request from launcher
This commit is contained in:
parent
79aa1cd730
commit
3fd28200ff
@ -166,14 +166,6 @@ internal static partial class Launcher
|
|||||||
Info.Log("g", "client updated");
|
Info.Log("g", "client updated");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!config.UUID.IsNullOrEmpty())
|
|
||||||
{
|
|
||||||
Info.Log("y", "uuid not found in config. requesting from server");
|
|
||||||
mainSocket.SendPackage("requesting uuid".ToBytes());
|
|
||||||
var uuid = mainSocket.GetPackage().BytesToString();
|
|
||||||
config.UUID = uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
config.Save();
|
config.Save();
|
||||||
// запуск майнкрафта
|
// запуск майнкрафта
|
||||||
Info.Log("g", "launching minecraft");
|
Info.Log("g", "launching minecraft");
|
||||||
|
|||||||
@ -113,7 +113,7 @@ static class Server
|
|||||||
}
|
}
|
||||||
// запрос от юзера
|
// запрос от юзера
|
||||||
|
|
||||||
if (FindUser(hash, out var user))
|
if (TryFindUser(hash, out var user))
|
||||||
{
|
{
|
||||||
Info.Log("b", "user is ", "c", user.name);
|
Info.Log("b", "user is ", "c", user.name);
|
||||||
handlerSocket.SendPackage("launcher".ToBytes());
|
handlerSocket.SendPackage("launcher".ToBytes());
|
||||||
@ -194,7 +194,7 @@ static class Server
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool FindUser(byte[] hash, out (string name, string uuid) user)
|
static bool TryFindUser(byte[] hash, out (string name, string uuid) user)
|
||||||
{
|
{
|
||||||
DtsodV23 usersdb = new(File.ReadAllText("users.dtsod"));
|
DtsodV23 usersdb = new(File.ReadAllText("users.dtsod"));
|
||||||
user = new();
|
user = new();
|
||||||
@ -207,16 +207,4 @@ static class Server
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static string GetUUID(string username)
|
|
||||||
{
|
|
||||||
var response=new HttpClient().GetAsync(
|
|
||||||
$"https://api.mojang.com/users/profiles/minecraft/{username}")
|
|
||||||
.GetAwaiter().GetResult();
|
|
||||||
var content = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
|
|
||||||
JObject json = (JObject)JsonConvert.DeserializeObject(content)
|
|
||||||
?? throw new Exception("cant parse to json:\n"+content);
|
|
||||||
var uuid = json["id"] ?? throw new Exception("cant het id from json:\n"+content);
|
|
||||||
return uuid.Value<string>();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user