Solved Detect if a player is coming out of the water

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

Thread Status:
Not open for further replies.
  1. Hello, I'm making code to detect if a player is using "jesus" or water walking hacks and I need help detecting if they are coming out of the water, because this is whats breaking the code.
     
  2. Offline

    mine-care

    @someguyonthestreet sing player move wvent check if the location from block is water and the block at location to is not water. That means they are going off water
     
  3. @mine-care I am doing that but the problem is that when they are going out of the water they are standing above water and then it detects it but that is not how its supposed to be. This is why I created this post. If you would care to show me code wise on how to do it, I would appreciate it. I know spoonfeeding isn't a good habit but in this case I just don't understand it.
     
  4. Offline

    Reynergodoy

    Code:
          @EventHandler
          public void onPlayerHacks(PlayerMoveEvent e)
          {
            Player p = e.getPlayer();
            if (((e.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.WATER) || (e.getTo().getBlock().getRelative(BlockFace.DOWN).getType() == Material.STATIONARY_WATER)) &&
              (ArrayList.*playerarraylist*.contains(p.getName())))
            {
             p.performCommand("ban " + p.getName())
              return;
              }
            }
    idk if it works, i still haven't tested
     
  5. Offline

    MrFrozen

    I think see if the player floats above water or if the player quikly go up and down on the top of water. you should use some good maths

    I think that will also ban normal users, not sure but probably it will

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

    Reynergodoy

    hmm... idk... because i tested without hacks and i haven't been banned
     
  7. Offline

    MrFrozen

    He should test it also with server lagg or user end lagg on internet it will take a lot of tests
     
  8. @MrFrozen
    I have tried it with an old method and it doesn't work but I didn't have that arraylist part and I don't understand why you have it in yours. It gives the same error as my other code.

    This is my code:
    @MrFrozen @MrFrozen @mine-care
    Code:
    @EventHandler
        public void onWaterWalk(final PlayerMoveEvent event) {
            final Player player = event.getPlayer();
           
            if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.WATER || player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.STATIONARY_WATER) {
                task = Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Main.get(), new Runnable() {
                    public void run() {
                        if (player.isOnline()) {
                        if (player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.WATER || player.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() == Material.STATIONARY_WATER) {
                            if(player.getLocation().getBlock().getRelative(BlockFace.NORTH).getType() == Material.AIR || player.getLocation().getBlock().getRelative(BlockFace.WEST).getType() == Material.AIR || player.getLocation().getBlock().getRelative(BlockFace.EAST).getType() == Material.AIR || player.getLocation().getBlock().getRelative(BlockFace.SOUTH).getType() == Material.AIR){
                           
                                 //they are hacking but breaks when they don't have hacks and are coming out of the water
                                           
                                       
                                    }
                            }
                        } else {
                            Bukkit.getScheduler().cancelTask(task);
                        }
                    }
                }, 20L);
            }
        }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  9. Offline

    mine-care

    @Reynergodoy please avoid spoonfeeding peoplle :3 also what is ArrayList.*playerarraylist* ?
     
  10. @Reynergodoy To add on to the above: Please don't spoon-feed clearly broken code. What if someone's swimming in at least 2 deep water? There will be water below them, and your code will decide to ban them. Not through using the API for such a thing, though, it will try to force the player to ban themselves. If the player doesn't have permission to ban - which is very likely - then this method will fail. Additionally there's literally no point in a return at the end of a void method.

    @someguyonthestreet You've got it right there - methods like that will result in a player get accused of such when simply coming out of water, or swimming in places where there is air next to them (for example, in a waterfall)... Here's a hint: Get an anti-cheat plugin. If it blocks it, great. If it doesn't, then maybe it's not worth detecting.
     
  11. Offline

    Signatured

    Scenario:
    Player lags out of water, fires first catch. Player then attempts to jump back into water, scheduler ends right as player is above water block, boom banned. Maybe some sort of flagging system should be in order, and ban them after a certain amount of flags.
     
Thread Status:
Not open for further replies.

Share This Page