Package net.thenextlvl.worlds.api.link
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 TypeMethodDescriptiongetLinkTree(net.kyori.adventure.key.Key key) Retrieves theLinkTreeassociated with the specified key, if available.getLinkTree(org.bukkit.World world) Retrieves theLinkTreeassociated with the provided world, if available.Retrieves allLinkTreeinstances 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.booleanhasLinkTree(net.kyori.adventure.key.Key key) Checks if the specified world is associated with aLinkTree.booleanhasLinkTree(org.bukkit.World world) Checks if the specified world is associated with a LinkTree.booleanlink(org.bukkit.World source, org.bukkit.World target) Establishes a link between the specified source and destination world.booleanunlink(net.kyori.adventure.key.Key source, net.kyori.adventure.key.Key target) Removes the link between the specified source and target if it exists.booleanunlink(org.bukkit.World source, org.bukkit.World target) Removes the link between the specified source and target worlds if it exists.
-
Method Details
-
getLinkTrees
Retrieves allLinkTreeinstances managed by the provider.- Returns:
- a stream of all
LinkTreeinstances
-
getLinkTree
Retrieves theLinkTreeassociated 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
Retrieves theLinkTreeassociated 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 determinedtype- 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
sourceworld has to beNORMAL
The environment of thetargetworld has to be eitherNETHERorTHE_END
Thetargetworld may not be associated with a link tree- Parameters:
source- the source world from which the link is createdtarget- 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 linktarget- 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 removedtarget- 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 aLinkTree.- 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
-