ProfileFetcher Tool icon

ProfileFetcher Tool -----

A tool used for fetching player data



First we need to declare an instance of ProfileFetcher somewhere in order to use its functions (becareful, don't call that each time because of performance cost, it is designed to declared once).
Code (Java):
ProfileFetcher api = ProfileFetcher. API ( ) ;
Alternatively, you can customize your fetcher instance functionality by passing "FetcherOptions" as a parameter in constructor. you can build one easily in one line by calling chains of option setting functions, take a look at the example below:
Code (Java):
FetcherOptions options = FetcherOptions. create ( )
        . register ( new RequestHandler < String, Textures > (RequestType. USERNAME_TO_PROFILE, username -> null, 2000 ) )
        . setRequestExecutor (Executors. newFixedThreadPool ( 5 ) )
        . shouldIgnoreErrors ( true ) ;

ProfileFetcher api = ProfileFetcher. API (options ) ;
In this example we are registering a requester for (username to profile) which will do nothing, we also set an executor for completable futures to a fixed thread pool of 5 threads, and ignoring errors for sure, so if any exceptions thrown in the request functions, it will ignored and iterates to the next requester in order to fetch data.

Other usages of the api is pretty much straight-forward, but still, here is an example of setting player profile in PaperSpigot (1.19.4) (note the setProperty function):

Keep in mind that the function below completable futures, might not be launched under main thread, so you have to create a synchronized task and perform the non-thread-safe actions
Code (Java):
api. fetchTexturesAsync ( "md_5" ). whenComplete ( (textures, ex ) -> {
    Texture texture = textures. getMain ( ) ;

    player. sendMessage ( Component. text ( "Changed skin!" ) ) ;
    player. getPlayerProfile ( ). setProperty ( new ProfileProperty ( "textures", texture. value, texture. signature ) ) ;
    player. spigot ( ). respawn ( ) ; // Execute this sync
} ) ;
Thanks to (for default requesters):
- Ashcon
- Minetools
- Mojang Profile API
- MineSkin (InventiveTalentDev)
Resource Information
Author:
----------
Total Downloads: 116
First Release: Jun 23, 2023
Last Update: Jul 3, 2023
Category: ---------------
All-Time Rating:
0 ratings
Version -----
Released: --------------------
Downloads: ------
Version Rating:
----------------------
-- ratings