Spawn Command.

Discussion in 'Spigot Plugin Development' started by Nosmakos, May 28, 2016.

  1. hey guys i know how to make a command like "spawn", "setspawn" but i want to know how i can make a player to go to spawn only when he is for example 10 blocks away from the spawn set?

    Example here:

    SIDES .jpg
     
  2. Compare the players distance to the spawn set.

    double distance(Location o)
    Get the distance between this location and another.

    double distanceSquared(Location o)
    Get the squared distance between this location and another.
     
    • Agree Agree x 2
  3. It is worth noting that one should use distanceSquared over distance in situations that allow it since it is much cheaper on resources. You just will have to square your base value to make it work correctly. Discussion here if you want to read people's benchmarks and such.
     
    • Agree Agree x 1
  4. If you want the area to be circular, the methods above are your way.
    If you want the area to be quadratic, like in the graphic above, search for "bukkit check if player is in square area" or something similar.
    You should know how to define an area
     
  5. Thank you guys for letting me know! When i get back I. Will try to do this! Because I want to make a safeezone area with a jail and people have to be around the jail to enter it
     
    • Friendly Friendly x 1