Class MinecraftUuids
java.lang.Object
me.pauleff.common.handlers.uuid.MinecraftUuids
Provides pure helpers for Minecraft UUID generation, formatting, parsing, and classification.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringReturns the hyphenated string form of a UUID without dashes.static booleanChecks whether the given string is a well-formed Minecraft online or offline UUID.static UUIDofflineFromName(String name) Generates an offline-mode UUID for the given player name.static UUIDParses a hyphenated or dashless UUID string.static UUIDTypeDetermines whether a UUID is an online, offline, or invalid Minecraft UUID by version.
-
Method Details
-
offlineFromName
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- ifnameisnull
-
dashless
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- ifuuidisnull
-
parse
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- ifuuidStringisnullIllegalArgumentException- ifuuidStringis not a valid UUID string
-
typeOf
Determines whether a UUID is an online, offline, or invalid Minecraft UUID by version.Version
4is treated as online, version3as offline; any other version is invalid.- Parameters:
uuid- the UUID to classify- Returns:
- the corresponding
UUIDType - Throws:
NullPointerException- ifuuidisnull
-
isValid
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
3or4.- Parameters:
uuidString- the UUID string to validate- Returns:
trueif the string is a valid online or offline UUID;falseotherwise
-