Class TeleportLoader
This class allows registering and managing custom teleports that the pathfinder can use when calculating routes. Custom teleports supplement the built-in teleport definitions and are useful for adding support for new teleport methods or custom teleport items.
Teleports are used by the pathfinding system to find faster routes to destinations by considering teleportation as a movement option. Each teleport defines a destination, requirements, and the action to perform the teleport.
Example Usage:
// Create a custom teleport
Teleport customTeleport = Teleport.builder()
.destination(new WorldPoint(3200, 3200, 0))
.action(() -> {
// Perform the teleport action
Item teleTab = Inventory.getFirst("Custom teleport tab");
if (teleTab != null) {
teleTab.interact("Break");
}
})
.requirement(() -> Inventory.contains("Custom teleport tab"))
.build();
// Add the custom teleport
TeleportLoader.addCustomTeleport(customTeleport);
// Get all registered custom teleports
List<Teleport> teleports = TeleportLoader.getCustomTeleports();
// Remove a custom teleport when no longer needed
TeleportLoader.removeCustomTeleport(customTeleport);
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidaddCustomTeleport(Teleport teleport) Registers a new custom teleport with the pathfinding system.Retrieves the list of all registered custom teleports.static voidremoveCustomTeleport(Teleport teleport) Removes a custom teleport from the pathfinding system.
-
Constructor Details
-
TeleportLoader
public TeleportLoader()
-
-
Method Details
-
getCustomTeleports
Retrieves the list of all registered custom teleports.This returns a mutable list that can be modified directly, though using
addCustomTeleport(Teleport)andremoveCustomTeleport(Teleport)is preferred.- Returns:
- the list of custom teleports
-
addCustomTeleport
Registers a new custom teleport with the pathfinding system.Once added, this teleport will be considered by the pathfinder when calculating routes to destinations.
- Parameters:
teleport- the teleport to register
-
removeCustomTeleport
Removes a custom teleport from the pathfinding system.After removal, this teleport will no longer be considered by the pathfinder.
- Parameters:
teleport- the teleport to unregister
-