Interface DiscordLinkService

All Known Implementing Classes:
AccountLinkManager

public interface DiscordLinkService
A class which provides numerous methods to interact with the link module for EssentialsX Discord.
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets a map of all linked players, where the key is the Minecraft UUID and the value is the Discord ID.
    Gets the Discord ID linked to the given UUID or null if none is present.
    getUUID(String discordId)
    Gets the UUID linked to the given Discord ID or null if none is present.
    default boolean
    isLinked(String discordId)
    Checks if there is a Minecraft account linked to the given Discord ID.
    default boolean
    isLinked(UUID uuid)
    Checks if there is a Discord account linked to the given UUID.
    boolean
    linkAccount(UUID uuid, net.essentialsx.api.v2.services.discord.InteractionMember member)
    Links the given UUID to the given InteractionMember.
    boolean
    Unlinks the given UUID with its associated Discord account (if present).
    boolean
    unlinkAccount(net.essentialsx.api.v2.services.discord.InteractionMember member)
    Unlinks the given InteractionMember with its associated Minecraft account (if present).
  • Method Details

    • getDiscordId

      String getDiscordId(UUID uuid)
      Gets the Discord ID linked to the given UUID or null if none is present.
      Parameters:
      uuid - the UUID of the player to lookup.
      Returns:
      the Discord ID or null.
    • isLinked

      default boolean isLinked(UUID uuid)
      Checks if there is a Discord account linked to the given UUID.
      Parameters:
      uuid - the UUID to check.
      Returns:
      true if there is a Discord account linked to the given UUID.
    • getUUID

      UUID getUUID(String discordId)
      Gets the UUID linked to the given Discord ID or null if none is present.
      Parameters:
      discordId - The Discord ID to lookup.
      Returns:
      the UUID or null.
    • isLinked

      default boolean isLinked(String discordId)
      Checks if there is a Minecraft account linked to the given Discord ID.
      Parameters:
      discordId - the Discord ID to check.
      Returns:
      true if there is a Minecraft account linked to the given Discord ID.
    • linkAccount

      boolean linkAccount(UUID uuid, net.essentialsx.api.v2.services.discord.InteractionMember member)
      Links the given UUID to the given InteractionMember.

      This will automatically trigger role sync (if configured) for the given player if this method returns true.

      This method will return true if the accounts are successfully linked, or false if either the provided UUID or InteractionMember are already linked to another account.

      Parameters:
      uuid - The UUID of the target player.
      member - The InteractionMember to link to the target player.
      Returns:
      true if the accounts were linked successfully, otherwise false.
      Throws:
      IllegalArgumentException - if either of the UUID or InteractionMember are null.
      See Also:
    • unlinkAccount

      boolean unlinkAccount(UUID uuid)
      Unlinks the given UUID with its associated Discord account (if present).

      This will automatically trigger role unsync (if configured) for the given player if this method returns true.

      Parameters:
      uuid - The UUID of the player to unlink.
      Returns:
      true if there was an account associated with the given UUID, otherwise false.
      Throws:
      IllegalArgumentException - if the provided UUID is null.
    • unlinkAccount

      boolean unlinkAccount(net.essentialsx.api.v2.services.discord.InteractionMember member)
      Unlinks the given InteractionMember with its associated Minecraft account (if present).

      This will automatically trigger role unsync (if configured) for the given InteractionMember if this method returns true.

      Parameters:
      member - The InteractionMember to unlink.
      Returns:
      true if there was a linked Minecraft account associated with the given InteractionMember, otherwise false.
      Throws:
      IllegalArgumentException - if the provided InteractionMember is null.
    • getAllLinkedPlayers

      Map<String,String> getAllLinkedPlayers()
      Gets a map of all linked players, where the key is the Minecraft UUID and the value is the Discord ID. The returned map is immutable and cannot be modified.
      Returns:
      an immutable map of all linked players.