Skip to content

Asynchronous Mojang API wrapper targeting .NET 5 and above

License

Notifications You must be signed in to change notification settings

PotatoMaster101/mojapi

Repository files navigation

Mojang API

License: MIT .NET Nuget

Deprecation notice: This project will be archived once PotatoMaster101/MojSharp is completed.

An asynchronous Mojang API wrapper in C# targeting .NET 5 and above.

Build

Build with dotnet:

$ dotnet build -c Release

Test

Run unit tests on local PC:

$ dotnet test -c Release

Run unit tests in docker:

$ docker build -t mojapi .

Quick Start

I want to authenticate!

var auth = await new AuthenticationEndpoint(new Credentials("username", "password")).Request();
Console.WriteLine(auth.Token.AccessToken);
Console.WriteLine(auth.Token.ClientToken);

Who the hell is this guy? Give me his past names!

var player = await new SingleUuidEndpoint("player").Request();
var history = await new NameHistoryEndpoint(player.Player.Uuid).Request();

foreach (var (name, timestamp) in history.History)
    Console.WriteLine($"{name}, {timestamp}");

Give me this guy's skin! I like it!

var player = await new SingleUuidEndpoint("player").Request();
var profile = await new ProfileEndpoint(player.Player.Uuid).Request();
Console.WriteLine(profile.Texture.SkinUrl);

Let me change my skin!

Change skin to a local file:

var skin = new Skin("some/minecraft/skin.png", Skin.SlimStyle);     // or Skin.ClassicStyle
var upload = await new UploadSkinEndpoint("access token", skin).Request();
Console.WriteLine(upload.ChangedSkin.Url);

Change skin to a network image:

var skin = new Skin("https://some/online/skin.png", Skin.SlimStyle);    // or Skin.ClassicStyle
var upload = await new ChangeSkinEndpoint("access token", skin).Request();
Console.WriteLine(upload.ChangedSkin.Url);

More examples!

More sample projects can be found under examples/

About

Asynchronous Mojang API wrapper targeting .NET 5 and above

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published