https://github.com/potatomaster101/mojsharp
An asynchronous Mojang API wrapper targeting .NET 7 and above
https://github.com/potatomaster101/mojsharp
api api-wrapper async csharp dotnet mojang mojang-api
Last synced: 8 months ago
JSON representation
An asynchronous Mojang API wrapper targeting .NET 7 and above
- Host: GitHub
- URL: https://github.com/potatomaster101/mojsharp
- Owner: PotatoMaster101
- License: mit
- Created: 2021-11-12T11:27:50.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2023-03-12T09:32:27.000Z (over 2 years ago)
- Last Synced: 2025-02-01T15:48:24.947Z (8 months ago)
- Topics: api, api-wrapper, async, csharp, dotnet, mojang, mojang-api
- Language: C#
- Homepage:
- Size: 29.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Mojang Sharp
[](https://github.com/PotatoMaster101/MojSharp/blob/main/LICENSE)
[](https://github.com/PotatoMaster101/MojSharp/actions/workflows/dotnet.yml)
[](https://www.nuget.org/packages/MojSharp)An asynchronous [Mojang API](https://wiki.vg/Mojang_API) wrapper targeting [.NET 7](https://dotnet.microsoft.com/) and above.
## Building
Build with [`dotnet`](https://dotnet.microsoft.com/):
```
$ dotnet build -c Release
```## Testing
Run all unit tests with [`dotnet`](https://dotnet.microsoft.com/):
```
$ dotnet test -c Release
```## Quick Start
### Username -> UUID
**Single UUID**
```cs
var response = await new UuidRequest("PotatoMaster101").Request();
Console.WriteLine($"{response.Player.Username} : {response.Player.Uuid}");
```**Multiple UUID**
```cs
var users = new[] { "Notch", "PotatoMaster101" };
var response = await new MultiUuidRequest(users).Request();
foreach (var player in response.Players)
Console.WriteLine($"{player.Username} : {player.Uuid}");
```### UUID -> Profile
```cs
var response = await new ProfileRequest("cb2671d590b84dfe9b1c73683d451d1a").Request();
var texture = response.GetTextures();
Console.WriteLine($"Skin URL: {texture?.Skin?.Url}");
Console.WriteLine($"Alex Style: {texture?.Skin?.Slim}");
Console.WriteLine($"Cape URL: {texture?.CapeUrl}");
```### Blocked Servers
```cs
var response = await new BlockedServerRequest().Request();
Console.WriteLine(response.RawData);
```### Mojang Authentication
```cs
var response = await new AuthenticationRequest("username", "password").Request();
Console.WriteLine($"Client token: {response.ClientToken}");
Console.WriteLine($"Access token: {response.AccessToken}");
Console.WriteLine($"Username: {response.Profile.Username}");
Console.WriteLine($"UUID: {response.Profile.Uuid}");
```## Examples
Example projects can be found under `examples`.## TODO
- Implement rest of API including Microsoft auth