Need help reseting height

Discussion in 'Plugin Development' started by camji555, Aug 19, 2013.

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

    camji555

    For some reason I dont know why this code doesnt work. What I want is when players reach the height of 90, it will send them a message, and move them down 3 blocks. It doesnt seem to work. Please help!
    Code:java
    1. @EventHandler
    2. public void onPlayerMove(PlayerMoveEvent event) {
    3. Player player = event.getPlayer();
    4. int playerY = player.getLocation().getBlockY();
    5. if(!player.hasPermission("Woopa.height") || !player.isOp()){
    6. if(playerY >= 90){
    7. player.getLocation().setY(87);
    8. player.sendMessage(ChatColor.RED + "Not allowed to pass this height.");
    9. }
    10. }
    11. }
     
  2. Offline

    Lactem

    Try making playerY be event.getTo().getY(). Also, make sure you registered the listener in your main class.
     
  3. Offline

    Samthelord1

    camji555 it might be with you using player.getLocation() you should use something like

    Location location = player.getLocation();
    location.setY(87);
    player.teleport(location);
     
  4. Offline

    camji555

    Thanks alot! It works!
     
Thread Status:
Not open for further replies.

Share This Page