content: package better.anticheat.core.check.impl.combat;
  
  import better.anticheat.core.BetterAnticheat;
  import better.anticheat.core.check.Check;
  import better.anticheat.core.check.CheckInfo;
  import com.github.retrooper.packetevents.event.simple.PacketPlayReceiveEvent;
  import com.github.retrooper.packetevents.protocol.packettype.PacketType;
  import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity;
  
  /**
   * This check looks for self hits.
   */
  @CheckInfo(name = "SelfHit", category = "combat")
  public class SelfHitCheck extends Check {
  
      public SelfHitCheck(BetterAnticheat plugin) {
          super(plugin);
      }
  
      @Override
      public void handleReceivePlayPacket(PacketPlayReceiveEvent event) {
  
          /*
           * You cannot attack yourself.
           */
  
          if (event.getPacketType() != PacketType.Play.Client.INTERACT_ENTITY) return;
          WrapperPlayClientInteractEntity wrapper = new WrapperPlayClientInteractEntity(event);
          if (wrapper.getEntityId() == player.getUser().getEntityId()) fail();
      }
  }
  