Interface LinkProvider


@NullMarked public interface LinkProvider
LinkProvider defines an interface for managing and retrieving associations between worlds and their respective LinkTree structures. It allows querying linked worlds, establishing links, and managing portal relationships.
Since:
3.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    getLinkTree(net.kyori.adventure.key.Key key)
    Retrieves the LinkTree associated with the specified key, if available.
    getLinkTree(org.bukkit.World world)
    Retrieves the LinkTree associated with the provided world, if available.
    @Unmodifiable Stream<LinkTree>
    Retrieves all LinkTree instances managed by the provider.
    Optional<org.bukkit.World>
    getTarget(org.bukkit.World world, org.bukkit.PortalType type)
    Retrieves the target world associated with the specified source world, based on the given portal type.
    boolean
    hasLinkTree(net.kyori.adventure.key.Key key)
    Checks if the specified world is associated with a LinkTree.
    boolean
    hasLinkTree(org.bukkit.World world)
    Checks if the specified world is associated with a LinkTree.
    boolean
    link(org.bukkit.World source, org.bukkit.World target)
    Establishes a link between the specified source and destination world.
    boolean
    unlink(net.kyori.adventure.key.Key source, net.kyori.adventure.key.Key target)
    Removes the link between the specified source and target if it exists.
    boolean
    unlink(org.bukkit.World source, org.bukkit.World target)
    Removes the link between the specified source and target worlds if it exists.
  • Method Details

    • getLinkTrees

      @Contract(pure=true) @Unmodifiable Stream<LinkTree> getLinkTrees()
      Retrieves all LinkTree instances managed by the provider.
      Returns:
      a stream of all LinkTree instances
    • getLinkTree

      @Contract(pure=true) Optional<LinkTree> getLinkTree(net.kyori.adventure.key.Key key)
      Retrieves the LinkTree associated with the specified key, if available.
      Parameters:
      key - the key for which the associated LinkTree is to be retrieved
      Returns:
      an Optional containing the associated LinkTree
    • getLinkTree

      @Contract(pure=true) Optional<LinkTree> getLinkTree(org.bukkit.World world)
      Retrieves the LinkTree associated with the provided world, if available.
      Parameters:
      world - the world for which the associated LinkTree is to be retrieved
      Returns:
      an Optional containing the associated LinkTree
    • getTarget

      @Contract(pure=true) Optional<org.bukkit.World> getTarget(org.bukkit.World world, org.bukkit.PortalType type)
      Retrieves the target world associated with the specified source world, based on the given portal type. This method determines the destination world depending on the portal relationship and the environment of the source world.
      Parameters:
      world - the source world for which the target world is determined
      type - the type of portal that dictates the relationship between worlds (e.g., NETHER, ENDER)
      Returns:
      an Optional containing the target world if available
    • link

      boolean link(org.bukkit.World source, org.bukkit.World target)
      Establishes a link between the specified source and destination world. The link is created depending on the type of the destination world's environment.

      The environment of the source world has to be NORMAL
      The environment of the target world has to be either NETHER or THE_END
      The target world may not be associated with a link tree

      Parameters:
      source - the source world from which the link is created
      target - the target world to which the link is made
      Returns:
      true if the link was successfully created; false otherwise
      See Also:
    • unlink

      boolean unlink(net.kyori.adventure.key.Key source, net.kyori.adventure.key.Key target)
      Removes the link between the specified source and target if it exists. The operation ensures that the link is only removed if it is present in the associated link structure of the source world.
      Parameters:
      source - the key representing the source of the link
      target - the key representing the target of the link
      Returns:
      true if the link was successfully removed; false otherwise
    • unlink

      boolean unlink(org.bukkit.World source, org.bukkit.World target)
      Removes the link between the specified source and target worlds if it exists. The operation ensures that the link is only removed if it is present in the associated link structure of the source world.
      Parameters:
      source - the source world from which the link is to be removed
      target - the target world for which the link is to be removed
      Returns:
      true if the link was successfully removed; false otherwise
    • hasLinkTree

      @Contract(pure=true) boolean hasLinkTree(net.kyori.adventure.key.Key key)
      Checks if the specified world is associated with a LinkTree.
      Parameters:
      key - the key to check for an associated LinkTree
      Returns:
      whether the specified key has an associated LinkTree
    • hasLinkTree

      @Contract(pure=true) boolean hasLinkTree(org.bukkit.World world)
      Checks if the specified world is associated with a LinkTree.
      Parameters:
      world - the world to check for an associated LinkTree
      Returns:
      whether the specified world has an associated LinkTree