Class LocationUtil

java.lang.Object
com.sk89q.commandbook.util.LocationUtil

public class LocationUtil
extends java.lang.Object
  • Constructor Summary

    Constructors 
    Constructor Description
    LocationUtil()  
  • Method Summary

    Modifier and Type Method Description
    static double distanceSquared2D​(org.bukkit.Location a, org.bukkit.Location b)
    Get the 2D distance between two points a and b.
    static org.bukkit.World extractWorld​(org.bukkit.command.CommandSender sender)
    Try to extract the world of a command sender.
    static org.bukkit.Location findFreePosition​(org.bukkit.Location searchPos)
    Find a position for the player to stand that is not inside a block.
    static org.bukkit.Location getManagedLocation​(RootLocationManager<NamedLocation> manager, org.bukkit.World world, java.lang.String id)
    Get a location from a location manager.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • findFreePosition

      public static org.bukkit.Location findFreePosition​(org.bukkit.Location searchPos)
      Find a position for the player to stand that is not inside a block. Blocks above the player will be iteratively tested until there is a series of two free blocks. The player will be teleported to that free position.
      Parameters:
      searchPos - search position
      Returns:
    • extractWorld

      public static org.bukkit.World extractWorld​(org.bukkit.command.CommandSender sender)
      Try to extract the world of a command sender.
      Parameters:
      sender - command sender
      Returns:
      world or null
    • getManagedLocation

      public static org.bukkit.Location getManagedLocation​(RootLocationManager<NamedLocation> manager, org.bukkit.World world, java.lang.String id) throws com.sk89q.minecraft.util.commands.CommandException
      Get a location from a location manager.
      Parameters:
      manager - RootLocationManager to look in
      world -
      id - name of the location
      Returns:
      a Bukkit location
      Throws:
      com.sk89q.minecraft.util.commands.CommandException - if the location by said id does not exist
    • distanceSquared2D

      public static double distanceSquared2D​(org.bukkit.Location a, org.bukkit.Location b)
      Get the 2D distance between two points a and b.
      Parameters:
      a - first location
      b - second location
      Returns:
      squared 2D distance between the two points