将实体传送到某个位置
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
}