Class UUIDFetcher
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PatternPattern representing the allowed classic gamertags. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic UUIDApplies dashes to the given UUID.static UUIDFetcherGets the fetcher's current instance.abstract CompletableFuture<String> getName(long xuid) Gets a Bedrock player's name.abstract CompletableFuture<String> abstract UUIDgetOfflineUUID(String name) Calculates the specified Java player's offline UUIDv3 usingUUID.nameUUIDFromBytes(byte[]).abstract UUIDgetOnlineUUID(long xuid) Gets a Bedrock player's UUID.abstract CompletableFuture<UUID> getOnlineUUID(String name) Gets a Java or Bedrock player's UUID based on the input: a name starting withPlayerManager.getFloodgateUsernamePrefix()for a Bedrock player any other name for a Java playerabstract CompletableFuture<String> getSkinTextureURL(long xuid) Gets a Bedrock player's skin's texture's URL.abstract CompletableFuture<String> getSkinTextureURL(String name) Gets a Java or Bedrock player's skin's texture's URL based on the input: a name starting withPlayerManager.getFloodgateUsernamePrefix()for a Bedrock player any other name for a Java playerabstract CompletableFuture<String> getSkinTextureURL(UUID uuid) abstract CompletableFuture<UUID> Gets a Java (online or offline) or Bedrock player's UUID based on the input: a name starting withPlayerManager.getFloodgateUsernamePrefix()for a Bedrock player any other name whileChatPlugin.isOnlineMode()for a Java online player any other name while!ChatPlugin.isOnlineMode()for a Java offline playerabstract CompletableFuture<Long> Gets a Bedrock player's XUID by: their in-game username (a name starting withPlayerManager.getFloodgateUsernamePrefix()matchingPlayerManager.getUsernamePattern()) their gamertag (any other name)abstract longGets a Bedrock player's XUID.static booleanisValidClassicGamertag(String classicGamertag) Checks if the specified String is a valid classic gamertag.
-
Field Details
-
CLASSIC_GAMERTAG_PATTERN
Pattern representing the allowed classic gamertags.Note: Microsoft's classic gamertags' documentation is not exhaustive at all:
- commas (',') should be allowed in gamertags, however, out of ~40M accounts tracked by GeyserMC, none of these contains any; this pattern does not allow commas
- it is unclear whether space-only and number-only gamertags are allowed; this pattern does not perform that kind of validation
- it is unclear where and how many consecutive spaces are allowed; this pattern does not perform that kind of validation
Regex:
^[a-zA-Z0-9 ]{1,15}$- See Also:
-
-
Constructor Details
-
UUIDFetcher
public UUIDFetcher()
-
-
Method Details
-
getName
Gets a Java or Bedrock player's name based on the input:The future throws:
NoSuchElementExceptionif the UUID does not belong to a paid Java or Bedrock accountIOExceptionif a connection or JSON error occurs
- Parameters:
uuid- Java or Bedrock player's UUID- Returns:
- Java or Bedrock player's name
- Throws:
IllegalArgumentException- IfUUID.version()!= 0 &&UUID.version()!= 4
-
getName
Gets a Bedrock player's name.The future throws:
NoSuchElementExceptionif the XUID does not belong to a paid Bedrock accountIOExceptionif a connection or JSON error occurs
- Parameters:
xuid- Bedrock player's XUID- Returns:
- Bedrock player's name
-
getUUID
Gets a Java (online or offline) or Bedrock player's UUID based on the input:- a name starting with
PlayerManager.getFloodgateUsernamePrefix()for a Bedrock player - any other name while
ChatPlugin.isOnlineMode()for a Java online player - any other name while
!ChatPlugin.isOnlineMode()for a Java offline player
The future is instantly completed and will not throw any exception if specified name is not a Bedrock username and
!ChatPlugin.isOnlineMode().The future throws:
NoSuchElementExceptionif the name does not belong to a paid Java (ifChatPlugin.isOnlineMode()) or Bedrock accountIOExceptionif a connection or JSON error occurs
- Parameters:
name- Java (online or offline) or Bedrock player's name- Returns:
- Java (online or offline) or Bedrock player's UUID
- Throws:
IllegalArgumentException- If specified name!PlayerManager.isValidUsername(String)
- a name starting with
-
getOnlineUUID
Gets a Java or Bedrock player's UUID based on the input:- a name starting with
PlayerManager.getFloodgateUsernamePrefix()for a Bedrock player - any other name for a Java player
The future throws:
NoSuchElementExceptionif the name does not belong to a paid Java or Bedrock accountIOExceptionif a connection or JSON error occurs
- Parameters:
name- Java or Bedrock player's name- Returns:
- Java or Bedrock player's UUID
- Throws:
IllegalArgumentException- If specified name!PlayerManager.isValidUsername(String)
- a name starting with
-
getOnlineUUID
Gets a Bedrock player's UUID.This simply converts the specified XUID to its corresponding UUIDv0; no validation is performed.
- Parameters:
xuid- Bedrock player's XUID- Returns:
- Bedrock player's UUID
-
getOfflineUUID
Calculates the specified Java player's offline UUIDv3 usingUUID.nameUUIDFromBytes(byte[]).- Parameters:
name- Java player's offline name- Returns:
- Java player's offline UUIDv3
- Throws:
IllegalArgumentException- If specified name is a Bedrock username or!PlayerManager.isValidUsername(String)
-
getXUID
Gets a Bedrock player's XUID by:- their in-game username (a name starting with
PlayerManager.getFloodgateUsernamePrefix()matchingPlayerManager.getUsernamePattern()) - their gamertag (any other name)
The future throws:
NoSuchElementExceptionif the name does not belong to a paid Bedrock accountIOExceptionif a connection or JSON error occurs
- Parameters:
name- Bedrock player's name or gamertag- Returns:
- Bedrock player's XUID
- Throws:
IllegalArgumentException- If!PlayerManager.isValidUsername(String)&& !isValidClassicGamertag(String)
- their in-game username (a name starting with
-
getXUID
Gets a Bedrock player's XUID.This simply converts the specified UUIDv0 to its corresponding XUID; only a check on
UUID.version()is performed.- Parameters:
uuid- Bedrock player's UUID- Returns:
- Bedrock player's XUID
- Throws:
IllegalArgumentException- IfUUID.version()!= 0
-
getSkinTextureURL
Gets a Java or Bedrock player's skin's texture's URL based on the input:- a name starting with
PlayerManager.getFloodgateUsernamePrefix()for a Bedrock player - any other name for a Java player
The future throws:
NoSuchElementExceptionif the name does not belong to a paid Java or Bedrock account with a skinIOExceptionif a connection or JSON error occurs
All paid Java accounts have a default skin, but Bedrock ones do not. Skin texture URLs always point to
textures.minecraft.net.- Parameters:
name- Java or Bedrock player's name- Returns:
- Java or Bedrock player's skin's texture's URL
- Throws:
IllegalArgumentException- If specified name!PlayerManager.isValidUsername(String)
- a name starting with
-
getSkinTextureURL
Gets a Java or Bedrock player's skin's texture's URL based on the input:The future throws:
NoSuchElementExceptionif the UUID does not belong to a paid Java or Bedrock account with a skinIOExceptionif a connection or JSON error occurs
All paid Java accounts have a default skin, but Bedrock ones do not. Skin texture URLs always point to
textures.minecraft.net.- Parameters:
uuid- Java or Bedrock player's UUID- Returns:
- Java or Bedrock player's skin's texture's URL
- Throws:
IllegalArgumentException- IfUUID.version()!= 0 &&UUID.version()!= 4
-
getSkinTextureURL
Gets a Bedrock player's skin's texture's URL.The future throws:
NoSuchElementExceptionif the XUID does not belong to a paid Bedrock account with a skinIOExceptionif a connection or JSON error occurs
All paid Java accounts have a default skin, but Bedrock ones do not. Skin texture URLs always point to
textures.minecraft.net.- Parameters:
xuid- Bedrock player's XUID- Returns:
- Bedrock player's skin's texture's URL
-
getInstance
Gets the fetcher's current instance.- Returns:
- Current instance
-
dash
Applies dashes to the given UUID.Example: "e1b47c83541c4a2a91d0b382279e9017" ➝ "e1b47c83-541c-4a2a-91d0-b382279e9017"
- Parameters:
nonDashedUUID- UUID to dash- Returns:
- Dashed UUID
- Throws:
IllegalArgumentException- If specified UUID is invalid
-
isValidClassicGamertag
Checks if the specified String is a valid classic gamertag.- Parameters:
classicGamertag- Classic gamertag to check- Returns:
- Whether the specified classic gamertag is valid
- See Also:
-