How to check if a player is going up

Discussion in 'Plugin Development' started by Inparsian, Feb 27, 2017.

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

    Inparsian

    Hi, I'm having trouble telling if a player is going up, here is the code & an explanation.
    I have this code right here (it's the real problem)
    Code:
    from.getY() > to.getY()+0.04
    Now let's just say, I have several variables. From (from pos), p (player) and To (to pos).
    Code:
    Player p = e.getPlayer();
    Location to = e.getTo();
    Location from = e.getFrom();
    Still don't understand? Full code's right here
    Code:
    Player p = e.getPlayer();
                Location to = e.getTo();
                Location from = e.getFrom();
             
               if(p.getGameMode()!= GameMode.CREATIVE&& p.getGameMode()!= GameMode.SPECTATOR){// Checks gamemode, if it's not gamemode creative or spectator, then...
                 
                   // Hm, suspicious.. Are they supposed to fly like this?
                   if(from.getY()< to.getY()+0.04){// Checks if player is ascending
                     
                       // I am pretty sure we caught a hacker!
                       if(p.getFallDistance()> 2.4D){
                         
                           //Hacks confirmed, let's take action
                            e.setTo(from);
                            p.sendMessage("§c§lKraken §c» §7Please turn off §c§oFly§7!");
                            me.bukkit.firstplugin.Kraken.log(p.getName(), "Fly", "Flying when they should not be");
                       }
                   }
               }
    And yes, all that code is inside a PlayerMoveEvent.
    Please help.
     
  2. Offline

    MaxFireIce

  3. Offline

    Inparsian

    Of course, it's not checking if the player is going up, it's checking if it's going down?
     
  4. Offline

    Drkmaster83

    If their from position is greater than their current position plus a few decimals? You've got the symbol backwards m8...
     
    Last edited: Mar 2, 2017
    ipodtouch0218 likes this.
  5. Offline

    MaxFireIce

    @Inparsian Math is hard XD. If what @Drkmaster83 said doesn't work, just go look through your calculations.
     
Thread Status:
Not open for further replies.

Share This Page