Add distance check to TeleportEvent
In addition to checking if a player is on a vehicle, the update now also checks if the distance between the player's current location and the teleport destination is more than 5 blocks. If that's the case, the teleportation is cancelled.
This commit is contained in:
parent
e35bc71f96
commit
df875406e1
|
|
@ -18,6 +18,8 @@ public class TeleportEvent implements Listener {
|
|||
Player player = event.getPlayer();
|
||||
if (player.getVehicle() == null)
|
||||
return;
|
||||
if (event.getTo().distance(event.getFrom()) < 5)
|
||||
return;
|
||||
event.setCancelled(true);
|
||||
player.sendRichMessage("<red>Teleporting was cancelled. You can not be sitting, or mounted while teleporting.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user