java.lang.Object
me.github.simonplays15.betterbansystem.api.uuid.UUIDFetcher

public class UUIDFetcher extends Object
Class that retrieves UUIDs of players from the Mojang API or returns their offline UUID.
  • 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

      @Contract(pure=true) @NotNull public static @NotNull UUID getUUID (String playername)
      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

      @Contract(pure=true) public static UUID getUUIDOrOfflineUUID (String playername)
      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