Interface PlayerLink


public interface PlayerLink
The base class of the PlayerLink database implementation. The implementation is responsible for making a connection with the database and keeping that connection alive so that Floodgate (or a third party plugin) can check for example if a given player is linked.
  • Method Details

    • load

      void load()
      Called by Floodgate after the initialization of the class. In this method the implementation should start the connection with the database and create the collections if they don't exist already.
    • getLinkedPlayer

      @NonNull CompletableFuture<LinkedPlayer> getLinkedPlayer(@NonNull UUID bedrockId)
      Get a linked player by the bedrock uuid
      Parameters:
      bedrockId - the uuid of the bedrock player
      Returns:
      a completable future with the LinkedPlayer. The future will have a null value if that Bedrock player isn't linked
    • isLinkedPlayer

      @NonNull CompletableFuture<Boolean> isLinkedPlayer(@NonNull UUID playerId)
      Tells if the given player is a linked player
      Parameters:
      playerId - the uuid of the player to check, can be both a Java or a Bedrock uuid
      Returns:
      true if the player is a linked player
    • linkPlayer

      @NonNull CompletableFuture<Void> linkPlayer(@NonNull UUID bedrockId, @NonNull UUID javaId, @NonNull String username)
      Links a Java account to a Bedrock account.
      Parameters:
      bedrockId - the uuid of the Bedrock player
      javaId - the uuid of the Java player
      username - the username of the Java player
      Returns:
      a future holding void on success or completed exceptionally when failed
    • unlinkPlayer

      @NonNull CompletableFuture<Void> unlinkPlayer(@NonNull UUID javaId)
      Unlinks a Java account from a Bedrock account.
      Parameters:
      javaId - the uuid of the Java player
      Returns:
      a future holding void on success or completed exceptionally when failed
    • createLinkRequest

      @NonNull CompletableFuture<?> createLinkRequest(@NonNull UUID javaId, @NonNull String javaUsername, @NonNull String bedrockUsername)
      Creates a link request for the given Java player.
      Parameters:
      javaId - the uuid of the Java player
      javaUsername - the username of the Java player
      bedrockUsername - the username of the Bedrock player receiving the link request
      Returns:
      a future holding the result of the link request which will be a LinkRequestResult on failure and the link code (string) on success
    • verifyLinkRequest

      @NonNull CompletableFuture<LinkRequestResult> verifyLinkRequest(@NonNull UUID bedrockId, @NonNull String javaUsername, @NonNull String bedrockUsername, @NonNull String code)
      Verifies a link request for the given Bedrock player.
      Parameters:
      bedrockId - the uuid of the Bedrock player
      javaUsername - the username of the Java players who requested the link
      bedrockUsername - the username of the Bedrock player
      code - the code created in createLinkRequest(UUID, String, String)
      Returns:
      a future holding the result of the link verification
    • getName

      String getName()
      Returns the name of this database implementation. This will return null when Player Linking is disabled or when only Global Linking is used.
    • isEnabled

      boolean isEnabled()
      Return if account linking is enabled. The difference between enabled and allowed is that 'enabled' still allows already linked people to join with their linked account while 'allow linking' allows people to link accounts using the commands.
    • getVerifyLinkTimeout

      long getVerifyLinkTimeout()
      Returns the duration (in seconds) before a LinkRequest timeouts
    • isAllowLinking

      boolean isAllowLinking()
      Return if account linking is allowed. The difference between enabled and allowed is that 'enabled' still allows already linked people to join with their linked account while 'allow linking' allows people to link accounts using the commands.
    • isEnabledAndAllowed

      default boolean isEnabledAndAllowed()
    • stop

      void stop()
      Called when the Floodgate plugin is going to shutdown