I'm trying to detect where a player is and if they are at that location to perform a method. This is my code: Code: @EventHandler public void onPlayerMove(PlayerMoveEvent e) { Player player = e.getPlayer(); Location loc1 = new Location(Bukkit.getServer().getWorld("hub"), 0, 5, 0); if (player.getLocation().getX() == loc1.getX && player.getLocation().getY() == loc1.getY && player.getLocation().getZ() == loc1.getZ) { //Method } } Anyone know what i am doing wrong here?
Try use if(player.getLocation().getX() == <int x> && player.getLocation().getY() == <int y> ...) instead of making a new location and getting the x,y,z.
Still doesn't work... Just nothing happens, i even try making it print "Test" when they get to the location before the method, but it still doesn't come up :/ Am i doing the wrong method for such a thing?
Oh ffs lol im retarded sorry xD i made a new class for this listener and forgot ;-; EDIT: Just tested it... Doesn't work still, i tested it by sending a message when the event is called and that works, just the location part doesn't.
Ah ok, so i did that and it works but only when i am at 0.0 5.0 0.0, can i make it anywhere on 0, 5, 0? EDIT: Ahh don't worry, i did this: Code: if (player.getLocation().getX() >= X1 && player.getLocation().getX() <= X2 && player.getLocation().getZ() >= Z1 && player.getLocation().getZ() <= Z2) { And it works Thanks !