Package com.github.mafelp.accounts
Class MinecraftLinker
java.lang.Object
com.github.mafelp.accounts.MinecraftLinker
The class that handles linking on the minecraft side of things.
-
Field Summary
Modifier and TypeFieldDescriptionThe Map that contains as key thePlayer
that created the link token and as the Value anInteger
between 100,000 and 999,999. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
getLinkToken(org.bukkit.entity.Player player)
Checks thelinkableAccounts
list, if thePlayer
already has a linking token and if so, it returns the token from this map.linkToDiscord(org.javacord.api.entity.user.User user, int linkID)
The method used to create a linkedAccount
with a discord user and the linking ID of a minecraft Player.private static int
The method used to create a new Linking token, aka aRandom
, 6-Digit number, that is not already in the linkableAccounts list.
-
Field Details
-
linkableAccounts
The Map that contains as key thePlayer
that created the link token and as the Value anInteger
between 100,000 and 999,999.
-
-
Constructor Details
-
MinecraftLinker
public MinecraftLinker()
-
-
Method Details
-
getLinkToken
public static int getLinkToken(org.bukkit.entity.Player player)Checks thelinkableAccounts
list, if thePlayer
already has a linking token and if so, it returns the token from this map. If the player does not have a token yet, it creates one and adds it to thelinkableAccounts
map, associated with the player.- Parameters:
player
- The player to get the Linking Token from.- Returns:
- The Token used to link the account in discord.
-
randomLinkToken
private static int randomLinkToken()The method used to create a new Linking token, aka aRandom
, 6-Digit number, that is not already in the linkableAccounts list. This prevents two users from having the same linking token.- Returns:
- a random linking token.
-
linkToDiscord
The method used to create a linkedAccount
with a discord user and the linking ID of a minecraft Player.- Parameters:
user
- The discordUser
to link the minecraftPlayer
to.linkID
- The ID used for finding the correct minecraftPlayer
.- Returns:
- If the ID is a valid token, it returns the newly
Account
, which was added to the list of accounts. If the ID is invalid, it returns an empty account.
-