예제 #1
0
  @Override
  public void c_(EntityHuman entity) {
    if ((lastBounceId != entity.id || System.currentTimeMillis() - lastBounceTick > 1000)
        && entity.getBukkitEntity().getLocation().distanceSquared(getBukkitEntity().getLocation())
            <= 1) {
      EntityTargetEvent event =
          new NpcEntityTargetEvent(
              getBukkitEntity(),
              entity.getBukkitEntity(),
              NpcEntityTargetEvent.NpcTargetReason.NPC_BOUNCED);
      CraftServer server = ((WorldServer) world).getServer();
      server.getPluginManager().callEvent(event);

      lastBounceTick = System.currentTimeMillis();
      lastBounceId = entity.id;
    }

    if (lastTargetId == -1 || lastTargetId != entity.id) {
      EntityTargetEvent event =
          new NpcEntityTargetEvent(
              getBukkitEntity(),
              entity.getBukkitEntity(),
              NpcEntityTargetEvent.NpcTargetReason.CLOSEST_PLAYER);
      CraftServer server = ((WorldServer) world).getServer();
      server.getPluginManager().callEvent(event);
      lastTargetId = entity.id;
    }

    super.c_(entity);
  }
예제 #2
0
  @Override
  public boolean a(EntityHuman entity) {
    EntityTargetEvent event =
        new NpcEntityTargetEvent(
            getBukkitEntity(),
            entity.getBukkitEntity(),
            NpcEntityTargetEvent.NpcTargetReason.NPC_RIGHTCLICKED);
    CraftServer server = ((WorldServer) world).getServer();
    server.getPluginManager().callEvent(event);

    return super.a(entity);
  }