MineskinClient
v2 (#17)
api.mineskin.org 客戶端
可用於從皮膚圖像檔案產生有效的紋理資料。
您也可以使用mineskin.org直接從圖像生成皮膚數據。
該 API 需要官方 Minecraft 帳戶才能上傳皮膚紋理。
如果您擁有一個不經常使用的 Minecraft 帳戶,並且希望為 API 的速度做出貢獻,請在此處新增您的帳戶!
public class Example {
private static final MineSkinClient CLIENT = MineSkinClient . builder ()
. requestHandler ( JsoupRequestHandler :: new )
. userAgent ( "MyMineSkinApp/v1.0" )
. apiKey ( "your-api-key" )
. build ();
public static void main ( String [] args ) throws FileNotFoundException {
GenerateOptions options = GenerateOptions . create ()
. name ( "My Skin" )
. visibility ( Visibility . PUBLIC );
File file = new File ( "skin.jpg" );
CLIENT . generateUpload ( file , options )
. thenAccept ( response -> {
// get generated skin
Skin skin = response . getSkin ();
System . out . println ( skin );
})
. exceptionally ( throwable -> {
throwable . printStackTrace ();
if ( throwable instanceof CompletionException completionException ) {
throwable = completionException . getCause ();
}
if ( throwable instanceof MineSkinRequestException requestException ) {
// get error details
MineSkinResponse response = requestException . getResponse ();
System . out . println ( response . getMessageOrError ());
}
return null ;
});
CLIENT . getSkinByUuid ( "skinuuid" )
. thenAccept ( response -> {
// get existing skin
Skin skin = response . getSkin ();
System . out . println ( skin );
});
}
}
< depencies >
< dependency >
< groupId >org.mineskin</ groupId >
< artifactId >java-client</ artifactId >
< version >2.1.1-SNAPSHOT</ version >
</ dependency >
< dependency >
< groupId >org.mineskin</ groupId >
< artifactId >java-client-jsoup</ artifactId >
< version >2.1.1-SNAPSHOT</ version >
</ dependency >
<!-- alternatively use apache httpcommons -->
<!-- <dependency> -->
<!-- <groupId>org.mineskin</groupId> -->
<!-- <artifactId>java-client-apache</artifactId> -->
<!-- <version>2.1.1-SNAPSHOT</version> -->
<!-- </dependency> -->
<!-- ... or java 11 HttpRequest -->
<!-- <dependency> -->
<!-- <groupId>org.mineskin</groupId> -->
<!-- <artifactId>java-client-java11</artifactId> -->
<!-- <version>2.1.1-SNAPSHOT</version> -->
<!-- </dependency> -->
</ depencies >
< repositories >
< repository >
< id >inventive-repo</ id >
< url >https://repo.inventivetalent.org/repository/public/</ url >
</ repository >
</ repositories >