將實體傳送到某個位置

Entity toBeTeleported;    //The entity you want to teleport
Location teleportTo = new Location(world,x,y,z,yaw,pitch);    //The location to teleport to

boolean success = toBeTeleported.teleport(teleportTo);

if(success) {
    //Teleport was successful
}else {
    //Teleport wasn't successful
}

你還可以為你的傳送新增原因,以便你可以自定義外掛或其他人對你的原因的處理方式:

Entity toBeTeleported;    //The entity you want to teleport
Location teleportTo = new Location(world,x,y,z,yaw,pitch);    //The location to teleport to
PlayerTeleportEvent.TeleportCause cause;    //The cause you want the teleport to be of

boolean success = toBeTeleported.teleport(teleportTo, cause);

if(success) {
    //Teleport was successful
}else {
    //Teleport wasn't successful
}