[Lib] MineskinSponge - Easy texture to skin conversion

:runner: MineskinSponge - Easy texture to skin conversion

MineskinSponge is a library for Sponge plugins, which makes the creation of skins very simple. It uses the Mineskin API to sign skin data on the Mojang servers. All you need to provide is the texture and it does everything else for you. If you are not a plugin developer and you need this library for the plugins you use to work, just download it below and install it like you would install any other plugin. This library alone does not provide any gameplay features.

:open_file_folder: Downloads

:pencil: About

The author of the Mineskin website is Inventivetalent. If you like this library, you can do them a favor by donating a Minecraft account to speed up the website.

:hammer_pick: Integration

In your @Plugin annotation, add a dependency to this library. For example:

@Plugin(
        id = "customheads",
        name = "CustomHeads",
        description = "Create heads with custom textures with just a single command.",
        url = "https://github.com/Limeth/CustomHeads",
        authors = {
                "Limeth"
        },
        // This is what you should add:
        dependencies = {
                // Require version 1.3.1 of MineskinSponge or newer
                @Dependency(id = "mineskinsponge", version = "[1.3.1,)")
        }
)

Next, add the dependency to your build.gradle:

repositories {
    // ...
    maven {
        name = 'jitpack'
        url = 'https://jitpack.io'
    }
}

dependencies {
    // ...
    compile 'com.github.Limeth:MineskinSponge:v1.3.1'
}

You should now be able to access the MineskinService classes in your code. In order to get the API class, do the following:

MineskinService service = Sponge.getServiceManager().provide(MineskinService.class)
        .orElseThrow(() -> new IllegalStateException("Could not access the Mineskin service."));

Please note, that MineskinSponge may only be used after the GamePreInitializationEvent with Order#EARLY was called.
Getting the skin from a texture is as simple as:

CompletableFuture<SkinRecord> future = service.getSkin(Paths.get("Limeth.png"));

future.thenAccept(skinRecord -> {
    ItemStack skull = skinRecord.create();
    // Give the skull to a player
});

You can also use the Asset API to provide a texture:

// The path within the JAR would be: `assets/%PLUGIN_ID%/Limeth.png`
Asset asset = Sponge.getAssetManager().getAsset(plugin, "Limeth.png").get();
CompletableFuture<SkinRecord> future = service.getSkin(asset);

Downloaded skins are cached, so there’s no need to worry about calling the method several times for a single skin. You can check out the MineskinService.java file in the sources to see what you can do with the library.

Example plugin

For a full example, check out the sources of the CustomHeads plugin.

1 Like

Do you have any implementation pictures? This sounds neat.

I will upload an example plugin later today.

1 Like