Class MinecraftUuids

java.lang.Object
me.pauleff.common.handlers.uuid.MinecraftUuids

public final class MinecraftUuids extends Object
Provides pure helpers for Minecraft UUID generation, formatting, parsing, and classification.
  • Method Details

    • offlineFromName

      public static UUID offlineFromName(String name)
      Generates an offline-mode UUID for the given player name.

      Uses the standard Minecraft offline algorithm: UUID.nameUUIDFromBytes("OfflinePlayer:" + name).

      Parameters:
      name - the Minecraft player name
      Returns:
      the generated offline UUID
      Throws:
      NullPointerException - if name is null
    • dashless

      public static String dashless(UUID uuid)
      Returns the hyphenated string form of a UUID without dashes.

      Mojang APIs and some mod formats (for example FTB Quests) store UUIDs this way.

      Parameters:
      uuid - the UUID to format
      Returns:
      the 32-character dashless UUID string
      Throws:
      NullPointerException - if uuid is null
    • parse

      public static UUID parse(String uuidString)
      Parses a hyphenated or dashless UUID string.

      Accepts the standard 36-character form and the 32-character Mojang API form.

      Parameters:
      uuidString - the UUID string to parse
      Returns:
      the parsed UUID
      Throws:
      NullPointerException - if uuidString is null
      IllegalArgumentException - if uuidString is not a valid UUID string
    • typeOf

      public static UUIDType typeOf(UUID uuid)
      Determines whether a UUID is an online, offline, or invalid Minecraft UUID by version.

      Version 4 is treated as online, version 3 as offline; any other version is invalid.

      Parameters:
      uuid - the UUID to classify
      Returns:
      the corresponding UUIDType
      Throws:
      NullPointerException - if uuid is null
    • isValid

      public static boolean isValid(String uuidString)
      Checks whether the given string is a well-formed Minecraft online or offline UUID.

      Requires the standard 36-character hyphenated form and a UUID version of 3 or 4.

      Parameters:
      uuidString - the UUID string to validate
      Returns:
      true if the string is a valid online or offline UUID; false otherwise