Skip to content

Commit 97c045e

Browse files
Fixing safe player teleport
1 parent 0d45d22 commit 97c045e

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/main/java/de/redstoneworld/redutilities/player/Teleport.java

+11-4
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,23 @@
77
public class Teleport {
88

99
/**
10-
* This method teleports the player to the specified location. Before the teleport, however,
11-
* the velocity is set to zero so that the player does not take over any fall damage due to
12-
* the previous fall / fly. This is mainly relevant in the 'Survival-Mode'.
10+
* This method teleports the player to the specified location.
11+
* The velocity and fall-damage is set to zero so that the player
12+
* does not take over any fall damage due to the previous fall / fly.
13+
* This is mainly relevant in the 'Survival-Mode'.
1314
*
1415
* @param player (Player) the target player
1516
* @param targetLocation (Location) the target teleport-location
1617
*/
1718
public static void teleportSafely(Player player, Location targetLocation) {
19+
// Stop the player's velocity to prevent continued movement
1820
player.setVelocity(new Vector(0, 0, 0));
21+
22+
// Teleport the player to the target location
1923
player.teleport(targetLocation);
24+
25+
// Reset the fall distance to prevent fall damage
26+
player.setFallDistance(0);
2027
}
21-
28+
2229
}

0 commit comments

Comments
 (0)