Class MojangUtils

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

public final class MojangUtils extends Object
Utils class using mojang API.
  • 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
    • authenticateSession

      @Blocking @Internal @NotNull public static @NotNull com.google.gson.JsonObject authenticateSession(String loginUsername, String serverId, @Nullable @Nullable SocketAddress userSocket) throws IOException
      Throws:
      IOException