Found a player when execute a command

Discussion in 'Plugin Development' started by TheRayMirez, Apr 23, 2014.

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

    TheRayMirez

    Hi,

    I want to know what I have to do when I execute x command, it check if I am in the coordenates that I have to make this command, then it send me to the coordenates that I put in the config.

    This is what I have so far..

    Code:java
    1. if(commandLabel.equalsIgnoreCase("enter")){
    2. Player player = (Player) sender;
    3. double px = player.getLocation().getBlockX();
    4. double py = player.getLocation().getBlockY();
    5. double pz = player.getLocation().getBlockZ();
    6.  
    7. if((px < -63 && px > -58) && (py < 73 && py > 70) && (pz < -86 && pz > -80))
    8. {
    9. player.sendMessage(ChatColor.GREEN + "OK!");
    10. }
    11. else{
    12. player.sendMessage(ChatColor.RED + "NO");
    13. }

    Cordenates where I have to execute the command:
    [​IMG]

    Thank you.

    up

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  2. Offline

    GyllieGyllie

    what is it doing, I mean does it works or does it say no the whole time?
     
  3. Offline

    TheRayMirez

    No every time
     
  4. Offline

    SnipsRevival

    I think you want to switch your greater than and less than signs for the negative values.
     
  5. Offline

    GyllieGyllie

    try this

    Code:java
    1. Location command = new Location(Bukkit.getWorld(world), -60, 72, -83);
    2.  
    3. if (player.getLocation().distance(command) <= 3){
    4. //this will check if player is in a radius of 3 meters to the coördinates
    5. }
     
Thread Status:
Not open for further replies.

Share This Page