Entity entity; //The entity you want to teleport
Entity teleportTo; //The entity where you want <entity> to be teleported to
boolean success = entity.teleport(teleportTo); //Attempting to teleport.
if(success) {
//Teleport was successful
}else {
//Teleport wasn't successful
}
You can also add a cause to your teleport, so you can customize how your cause will be treated by your plugin or by others:
Entity entity; //The entity you want to teleport
Entity teleportTo; //The entity where you want <entity> to be teleported to
PlayerTeleportEvent.TeleportCause cause; //The cause you want the teleport to be of
boolean success = entity.teleport(teleportTo, cause); //Attempting to teleport.
if(success) {
//Teleport was successful
}else {
//Teleport wasn't successful
}