Help with checking where a player is and then doing something about it

Discussion in 'Plugin Development' started by Mortal_Wombat, Aug 4, 2014.

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


    I know I know the title is long lol but help me pwease <3.

    Ok So here is my code it works when i am checking the Y but nothing else! So i decided to check the location. So here is my code:

    ublic void onEnable() {

    Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
    public void run() {
    for (Player p : Bukkit.getServer().getOnlinePlayers()) {

    Location loc = new Location(p.getWorld(), -412, 4, 908);
    Location plt = new Location(p.getWorld(), -410, 4, 908 );

    if(p.getLocation() == (plt)){


    }, 0, 2);

    Just a note i get no errors so idk what to do anymore DX.

    Thanks in advance!
  2. Offline


    1. You use == instead of .equals() - google why that's wrong
    2. Locations use double precision floats, so there is almost no chance two locations will ever be the same.
  3. Offline


    Mortal_Wombat lookup what _LB said, and i belive you have to round each part of the location to match it so round x of location 1 and round x of location 2 and then check if they match. <not sure>
    1. PS please use the code feature next time!
Thread Status:
Not open for further replies.

Share This Page