How would I make a /home command or /setspawn.

Discussion in 'Plugin Development' started by stantheman68, Oct 2, 2012.

Thread Status:
Not open for further replies.
  1. Offline

    stantheman68

    Hi bukkit,
    Just wondering a couple things.
    First off,

    In the code:
    player.getWorld().setSpawnLocation(arg0, arg1, arg2);
    What would I put as the args?
    And second,
    How would I make a /sethome command?
    Thanks for your help.
     
  2. Offline

    krazytraynz

    The arguments would have to be ints, and I'm fairly sure it would have to be the x, y, and z coordinates of the player. So you could do something like this:
    Code:
    int x = player.getLocation().getBlockX();
    int y = player.getLocation().getBlockY();
    int z = player.getLocation().getBlockZ();
    player.getWorld().setSpawnLocation(x, y, z);
    
     
  3. Offline

    Tzeentchful

    For the player.getWorld().setSpawnLocation(arg0, arg1, arg2);
    the args are the xyz coordinates in the world.
    it will also accept a Location object.
    eg:
    Code:
    player.getWorld().setSpawnLocation(player.getLocation());
    that would set the spawn point of the world to where the player is standing.

    as for the set home you are going to need to store a location in a file for each player.
    A YML file would probably be easiest. Have a look at creating custom config files here.
    then just simply get the xyz coordinates of the player when they do /sethome and save it
    to there own YML file.
     
  4. Offline

    stantheman68

    It does not work for
    some reason, it says that it cannot accept it or something. Is there any type of code to get the players cords?

    Thank You
    Thank You very much.
    ( It worked )

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 29, 2016
  5. Offline

    Tzeentchful

    oops my fault i was thinkg about a different method.
    this should work.
    Code:
    Location l = player.getLocation();
    player.getWorld().setSpawnLocation(l.getX(), l.gety(), getz());
     
Thread Status:
Not open for further replies.

Share This Page