Solved Check if a player is using high jump hacks

Discussion in 'Plugin Development' started by someguyonthestreet, May 19, 2015.

Thread Status:
Not open for further replies.
  1. I'm trying to detect if a player is using high jump hacks. This is what I have so far but it doesn't work.
    Code:
    Code:
    @EventHandler
        public void onHighJump(final PlayerMoveEvent event) {
            final Player player = event.getPlayer();
          
            Bukkit.getScheduler().scheduleSyncRepeatingTask(Main.get(), new Runnable() {
                public void run() {
                         if(player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR){
                                  if (event.getTo().getY() - event.getFrom().getY() >= 2) {
                                      if (!player.hasPotionEffect(PotionEffectType.JUMP)) {
                                          player.sendMessage("Hacking");
                             }
                         }
                    }
                }
            }, 20L, 20L);
        }
    I had it at 3 but i just kept it at two for testing purposes.
     
  2. Offline

    vhbob

  3. Offline

    Signatured

    Unfortunately there's not. You'll have to make your own way to detect a player jumping.
     
  4. Offline

    Koobaczech

    Use PlayerMoveEvent, check if their velocity is positive or negative, check if they have flight enabled or are flying, check if the material under them is Air, compare their upwards velocity to that of what you would consider to be a normal jump velocity. And then if it exceeds that they might be oOxXH4ck531137ingXxOo
     
  5. @Koobaczech @Signatured @vhbob
    How would I check if there y went up by 3? Because my current way is wrong and doesn't work
    @Koobaczech I don't know how to check the velocity, if you could help me out

    My Current Code(not working):
    Code:
        @EventHandler(priority = EventPriority.HIGHEST)
        public void onMove(PlayerMoveEvent event) {
            final Player player = event.getPlayer();
            final Location from = event.getFrom();
            Location to = event.getTo();
           
            if (from.getY() != to.getY()) {
                if (to.getY() > from.getY()) {
                    if (to.getY() - from.getY() > 2) {
                        if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.AIR) {
                            if (player.getGameMode() != GameMode.CREATIVE) {
                                if (!player.hasPotionEffect(PotionEffectType.JUMP)) {
                                    if (!player.getAllowFlight() && !player.isFlying()) {
                                        player.sendMessage("High Jump");
                                    }
                                }
                            }
                        }
                    }
                }
            }
           
           
        }
     
    Last edited: May 19, 2015
  6. Offline

    vhbob

    @someguyonthestreet i think the problome is that this code is run every milisecond the player is in motion, so the from will never be much less then the to
     
  7. Offline

    arhlex

    I think this should work;

    Code:
        @EventHandler(priority = EventPriority.HIGHEST)
        public void onMove(PlayerMoveEvent event) {
            Player player = event.getPlayer();
            Location from = event.getFrom();
            Location to = event.getTo();
            double fromy = from.getY();
            double toy = to.getY();
              if (player.getGameMode() != GameMode.CREATIVE) 
                 if (!player.hasPotionEffect(PotionEffectType.JUMP)) { 
                   if (!player.getAllowFlight() && !player.isFlying()) {
                     if (fromy - toy >= 2 && fromy > toy || toy - fromy >= 2 && fromy > toy) {
                    //Prevent hack, cancelling it or teleporting him back
                }
              }
            }
          }
     
  8. Offline

    Ward1246

    The code should be something like:
    Code:
             @EventHandler
             public void onPlayerMove(PlayerMoveEvent event) {
                 Player player = event.getPlayer();
                 if (!(player.isFlying())) // player is not flying
                 if (!(player.hasPotionEffect(PotionEffectType.JUMP))) // player does not have jump boost
                     if (player.getVelocity().getY() > 1) // player's velocity is higher than when a player jumps, you may want to play around with this, set it to a slightly lower value
                 player.sendMessage("You are most likely hacking! Turn off your jump boost mods now!");
             }
    
    This is like the post above mine, except i shortened the code, and tested for velocity.
     
    Last edited: May 19, 2015
  9. Offline

    bohafr

    @arthlex no.. You have to subtract to - from, check if to is bigger than to... Why? When you use from - to, when player falls it can call funcion, which have to do when player have hacks..
     
  10. lol all you people are giving bad methods, i fixed this myself. Thanks for trying to help
     
  11. Offline

    Ward1246

    Uhh, Those were all good methods. I know i tested mine and it worked. Though there are tons of solutions so there could be one that is better.
     
  12. @Ward1246 I literally tried all of them, they didn't work or they gave too many false positives. I'm saying thanks to them because they at least tried to help me by giving me the code so I appreciate it. I know that I might have said it in a bad way but that was early in the morning.
     
  13. Offline

    Evaluations

    Pretty ignorant but
     
  14. @Evaluations I understand that I shouldn't have written that message in such a way but if you read the post underneath it I say it in a nicer way.
     
Thread Status:
Not open for further replies.

Share This Page