Class UtilTeleport
java.lang.Object
net.lewmc.essence.teleportation.tp.UtilTeleport
Essence's teleportation utility.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumUsed to communicate the direction of a safe location search.static final record -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintcooldownRemaining(org.bukkit.entity.Player player, String type) Gets the amount of time remaining on a specific type of cooldown.booleancooldownSurpassed(org.bukkit.entity.Player player, String type) Checks if the cooldown has surpassed for a specific type of teleportation.voiddoTeleport(org.bukkit.entity.Player player, org.bukkit.Location location, int delay, boolean doLastLocUpdate) Teleports a player.voiddoTeleport(org.bukkit.entity.Player player, org.bukkit.World world, double X, double Y, double Z, float yaw, float pitch, int delay, boolean doLastLocUpdate) Creates a location to teleport a player, then teleports them.static org.bukkit.LocationfindFurthestLocation(org.bukkit.Location origin, UtilTeleport.Direction direction, org.bukkit.entity.Player player) Finds a safe location relative to the origin point.static UtilTeleport.LevelLocationfindLevelLocation(org.bukkit.Location origin, UtilTeleport.Direction direction, Integer levels, org.bukkit.entity.Player player) Finds a safe location to teleport a player to, given a direction and number of levels.voidsendToSpawn(org.bukkit.entity.Player player, String spawnName) Sends a player back to spawn.voidsetCooldown(org.bukkit.entity.Player player, String type) Sets the cooldown for a specific type of teleportation.voidsetTeleportStatus(org.bukkit.entity.Player player, boolean teleportInFuture) Sets a player's teleport status.booleanteleportIsValid(org.bukkit.entity.Player player) Gets a player's teleport status.booleanteleportToggleCheck(org.bukkit.entity.Player requester, org.bukkit.entity.Player target) Is the teleport blocked by the teleport toggle?
-
Constructor Details
-
UtilTeleport
Constructor for the TeleportUtil class.- Parameters:
plugin- Reference to the main Essence class.
-
-
Method Details
-
cooldownSurpassed
Checks if the cooldown has surpassed for a specific type of teleportation.- Parameters:
player- Player - The player to querytype- String - The type of teleportation.- Returns:
- boolean - If the cooldown has surpassed or not.
-
setCooldown
Sets the cooldown for a specific type of teleportation.- Parameters:
player- Player - The player to set the cooldown for.type- String - The type of cooldown.
-
cooldownRemaining
Gets the amount of time remaining on a specific type of cooldown.- Parameters:
player- Player - The player to set the cooldown for.type- String - The type of cooldown.- Returns:
- int - The amount of time remaining.
-
doTeleport
public void doTeleport(org.bukkit.entity.Player player, org.bukkit.World world, double X, double Y, double Z, float yaw, float pitch, int delay, boolean doLastLocUpdate) Creates a location to teleport a player, then teleports them.- Parameters:
player- Player - The player to teleport.world- World - The world to teleport them to.X- double - The X coordinate.Y- double - The Y coordinate.Z- double - The Z coordinate.yaw- float - The yaw.pitch- float - The pitchdelay- int - The time to wait before teleporting.
-
doTeleport
public void doTeleport(org.bukkit.entity.Player player, org.bukkit.Location location, int delay, boolean doLastLocUpdate) Teleports a player.- Parameters:
player- Player - The player to teleport.location- Location - The location to teleport them to,delay- int - The amount of time to wait before teleporting.
-
setTeleportStatus
public void setTeleportStatus(org.bukkit.entity.Player player, boolean teleportInFuture) Sets a player's teleport status.- Parameters:
player- Player - The player to teleport.teleportInFuture- boolean - Is the teleport happening in the future?
-
teleportIsValid
public boolean teleportIsValid(org.bukkit.entity.Player player) Gets a player's teleport status.- Parameters:
player- Player - The player to teleport.- Returns:
- boolean - Is valid?
-
teleportToggleCheck
public boolean teleportToggleCheck(org.bukkit.entity.Player requester, org.bukkit.entity.Player target) Is the teleport blocked by the teleport toggle?- Parameters:
requester- The player requesting the teleport.target- The target of the teleport.- Returns:
- true - Teleport can proceed, false - Teleport should be blocked.
-
findFurthestLocation
public static org.bukkit.Location findFurthestLocation(org.bukkit.Location origin, UtilTeleport.Direction direction, org.bukkit.entity.Player player) Finds a safe location relative to the origin point.- Parameters:
origin- The starting location.direction- The direction to search.- Returns:
- A safe location, or null if none found.
-
findLevelLocation
public static UtilTeleport.LevelLocation findLevelLocation(org.bukkit.Location origin, UtilTeleport.Direction direction, Integer levels, org.bukkit.entity.Player player) Finds a safe location to teleport a player to, given a direction and number of levels.- Parameters:
origin- The location to start searching from.direction- The direction to search in.levels- The number of levels to search.player- The player to check for safe locations.- Returns:
- A LevelLocation containing the safe location and the number of levels searched, or null if no safe location is found.
-
sendToSpawn
Sends a player back to spawn.- Parameters:
player- Player - The player.spawnName- String - the spawn's name
-