Advertisement
Guest User

AntiCheat

a guest
Sep 29th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. public void onHit(EntityDamageByEntityEvent e) {
  2.  
  3.     if (!(e.getDamager() instanceof Player))
  4.         return;
  5.     if (!(e.getEntity() instanceof Player))
  6.         return;
  7.     if (e.isCancelled())
  8.         return;
  9.     if (((LivingEntity) e.getEntity()).getNoDamageTicks() > ((LivingEntity) e
  10.         .getDamager()).getMaximumNoDamageTicks() / 2D)
  11.         return;
  12.  
  13.     Player p = (Player) e.getDamager();
  14.     Player t = (Player) e.getEntity();
  15.  
  16.     if (p.hasMetadata("NPC"))
  17.         return;
  18.     if (t.hasMetadata("NPC"))
  19.         return;
  20.  
  21.     if (t.isOnGround()) {
  22.  
  23.         Location l = new Location(p.getWorld(), p.getLocation().getX(), 0,
  24.             p.getLocation().getZ());
  25.         Location o = new Location(t.getWorld(), t.getLocation().getX(), 0,
  26.             t.getLocation().getZ());
  27.  
  28.         CheatData pd = main.getPlayerData(p);
  29.  
  30.         pd.groundHit(l.distanceSquared(o));
  31.  
  32.     } else {
  33.  
  34.         Location l = new Location(p.getWorld(), p.getLocation().getX(), 0,
  35.             p.getLocation().getZ());
  36.         Location o = new Location(t.getWorld(), t.getLocation().getX(), 0,
  37.             t.getLocation().getZ());
  38.  
  39.         CheatData pd = main.getPlayerData(p);
  40.  
  41.         pd.doubleHit(l.distanceSquared(o));
  42.  
  43.     }
  44.  
  45.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement