Sneak Help

Discussion in 'Spigot Plugin Development' started by OopsyPoopsy, Apr 25, 2017.

  1. Hello Spigot.
    I have this code to detect people who are using sneak hacks. But there's a problem, if you jump and sneak mid air before hitting the ground, you will be alerted for sneak. Anyone help me fix this? Thank you!

    Snip of the code:
    Code (Java):

    @EventHandler

    public void onSneakX(PlayerMoveEvent e) {

    if (plugin.getConfig().getString("sneak").equals("true")) {

    Player p = e.getPlayer();


    Location loc1 = e.getFrom();

    Location loc2 = e.getTo();


    if (p.isSneaking()) {

    if (loc1.getX() > loc2.getX()) {

    if (loc1.getX() - loc2.getX() >= 0.2) {

    if (p.isOnGround() && !p.getAllowFlight()) {

    if (e.getFrom().getY() == e.getTo().getY()) {

    p.teleport(loc1);

    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "vios " + p.getName() + " Sneak");

    for (Player staff : Bukkit.getServer().getOnlinePlayers()) {

    if (staff.hasPermission("beta.notify")) {

    staff.sendMessage(plugin.getConfig().getString("alerts").replace("&", "ยง").replace("%player", p.getName()).replace("%hack", "Sneak"));

    }

    }

    }

    }

    }

    }


    }

    }

    }
     
     
  2. Maybe you meant if(!p.isOnGround() && !p.getAllowFligjt())

    The way it's written that is only true if they ARE on the ground and don't have flight allowed


    Sent from my iPhone using Tapatalk
     
  3. Maybe you meant if(!p.isOnGround() && !p.getAllowFligjt())

    The way it's written that is only true if they ARE on the ground and don't have flight allowed


    Sent from my iPhone using Tapatalk
     
  4. If they're not on the ground, they'd have to be flying. This is to make sure they are on the ground, I don't want it to check if they are in the air.