Class MojangUtils

java.lang.Object
net.minestom.server.utils.mojang.MojangUtils

public final class MojangUtils extends Object
Utils class using mojang API.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static @Nullable com.google.gson.JsonObject
    fromUsername(@NotNull String username)
    Gets a JsonObject with the response from the mojang API
    static @Nullable com.google.gson.JsonObject
    fromUuid(@NotNull String uuid)
    Gets a JsonObject with the response from the mojang API
    static @Nullable com.google.gson.JsonObject
    fromUuid(@NotNull UUID uuid)
    Gets a JsonObject with the response from the mojang API
    static @NotNull String
    getUsername(UUID playerUUID)
    Gets a player's username from their UUID
    static @NotNull UUID
    getUUID(String username)
    Gets a player's UUID from their username

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MojangUtils

      public MojangUtils()
  • Method Details

    • getUUID

      @Blocking @NotNull public static @NotNull UUID getUUID(String username) throws IOException
      Gets a player's UUID from their username
      Parameters:
      username - The players username
      Returns:
      The UUID
      Throws:
      IOException - with text detailing the exception
    • getUsername

      @Blocking @NotNull public static @NotNull String getUsername(UUID playerUUID) throws IOException
      Gets a player's username from their UUID
      Parameters:
      playerUUID - The UUID of the player
      Returns:
      The player's username
      Throws:
      IOException - with text detailing the exception
    • fromUuid

      @Blocking @Nullable public static @Nullable com.google.gson.JsonObject fromUuid(@NotNull @NotNull UUID uuid)
      Gets a JsonObject with the response from the mojang API
      Parameters:
      uuid - The UUID as a UUID
      Returns:
      The JsonObject or null if the mojang API is down or the UUID is invalid
    • fromUuid

      @Blocking @Nullable public static @Nullable com.google.gson.JsonObject fromUuid(@NotNull @NotNull String uuid)
      Gets a JsonObject with the response from the mojang API
      Parameters:
      uuid - The UUID as a String
      Returns:
      The JsonObject or null if the mojang API is down or the UUID is invalid
    • fromUsername

      @Blocking @Nullable public static @Nullable com.google.gson.JsonObject fromUsername(@NotNull @NotNull String username)
      Gets a JsonObject with the response from the mojang API
      Parameters:
      username - The username as a String
      Returns:
      The JsonObject or null if the mojang API is down or the username is invalid