Solved Teleporting a player to coordinates

Discussion in 'Spigot Plugin Development' started by Wilsoon, Jan 27, 2020.

Thread Status:
Not open for further replies.
  1. So I figured out player.teleport() should be the thing I'm looking for to teleport a player to coordinates.
    upload_2020-1-27_8-15-14.png
    However I can't seem to figure out why it is a boolean and how do I format "Location"?
    What could I put for TeleportCause then?
    I searched up on Google and couldn't find how to do it, so here I am.




    EDIT:
    Another question, how do I get a value of anything that is inside two categories:
    Example:

    Code (YAML):
    settings:
       minecraft
    :
               x
    :
               y
    :
               z
    :
    How do I get for example the value of x?
     
  2. FrostedSnowman

    Resource Staff

    use the Location constructor. new Location(world, x, y, z) or the other constructor which also accepts pitch and yaw after the 3 coordinates.

    to get the value of x, you navigate through the nested sections by periods.

    getConfig().getDouble(“settings.minecraft.x”);

    Alternatively you can break up the config sections and read the inner sections. For simple cases, as such, traversing with the period makes most sense.
     
  3. Thanks!
     
Thread Status:
Not open for further replies.