Class UUIDFetcher
java.lang.Object
me.github.simonplays15.betterbansystem.api.uuid.UUIDFetcher
Class that retrieves UUIDs of players from the Mojang API or returns their offline
UUID.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull UUID
Retrieves the UUID for a given player name.static UUID
getUUIDOrOfflineUUID
(String playername) Returns the UUID of a player based on their name.static void
Loads the user cache from the JSON file.
-
Constructor Details
-
UUIDFetcher
public UUIDFetcher()
-
-
Method Details
-
loadUsercacheJson
public static void loadUsercacheJson()Loads the user cache from the JSON file. If the JSON file doesn't exist, the method returns. The method reads the JSON file using a buffered reader. It then converts the JSON data to a JsonArray using a Gson library. For each JsonElement in the JsonArray, the method retrieves the UUID and name values from the JsonObject. If the UUID is not already stored in the UUID bin file, it is saved using the saveUUIDToBin method. -
getUUID
Retrieves the UUID for a given player name.- Parameters:
playername
- the name of the player- Returns:
- the UUID of the player
- Throws:
RuntimeException
- if failed to call the Mojang API for UUID fetching
-
getUUIDOrOfflineUUID
Returns the UUID of a player based on their name. If the UUID is not found, it generates an offline UUID based on the player's name.- Parameters:
playername
- the name of the player- Returns:
- the UUID of the player or an offline generated UUID
-