mirror of
https://github.com/yawaflua/spworlds-csharp-library.git
synced 2025-12-10 04:29:25 +02:00
update
This commit is contained in:
33
Types/User.cs
Normal file
33
Types/User.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using spworlds;
|
||||
using System.Text.Json.Nodes;
|
||||
namespace spworlds.Types;
|
||||
|
||||
public class User
|
||||
{
|
||||
public string Name { get; }
|
||||
public string Uuid { get; }
|
||||
|
||||
public bool IsPlayer() => Name != null ? true : false;
|
||||
|
||||
public User(string name, string uuid)
|
||||
{
|
||||
Name = name;
|
||||
Uuid = uuid;
|
||||
}
|
||||
|
||||
public static async Task<User> CreateUser(string name)
|
||||
{
|
||||
string uuid;
|
||||
using(HttpClient client = new())
|
||||
{
|
||||
uuid = (string)JsonNode.Parse(await client.GetStringAsync($"https://api.mojang.com/users/profiles/minecraft/{name}"))["id"];
|
||||
}
|
||||
User user = new(name, uuid);
|
||||
return user;
|
||||
}
|
||||
|
||||
public string GetSkinPart(SkinPart skinPart, string size = "64")
|
||||
{
|
||||
return (string)$"https://visage.surgeplay.com/{skinPart}/{size}/{this.Uuid}";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user