private void tickNpcs() {
        for (NPC npc : this.npcRegistry) {
            if (!npc.isSpawned() || !npc.hasTrait(ClickableTrait.class)) continue;

            Npc helperNpc = npc.getTrait(ClickableTrait.class).npc;

            // ensure npcs stay in the same position
            Location loc = npc.getEntity().getLocation();
            if (loc.getBlockX() != helperNpc.getInitialSpawn().getBlockX() || loc.getBlockZ() != helperNpc.getInitialSpawn().getBlockZ()) {
                npc.teleport(helperNpc.getInitialSpawn().clone(), PlayerTeleportEvent.TeleportCause.PLUGIN);
            }

            // don't let players stand near npcs
            for (Entity entity : npc.getStoredLocation().getWorld().getNearbyEntities(npc.getStoredLocation(), 1.0, 1.0, 1.0)) {
                if (!(entity instanceof Player) || this.npcRegistry.isNPC(entity)) continue;

                final Player p = (Player) entity;

                if (p.getGameMode() == GameMode.CREATIVE || p.getGameMode() == GameMode.SPECTATOR) {
                    continue;
                }

                if (npc.getEntity().getLocation().distance(p.getLocation()) < 3.5) {
                    p.setVelocity(p.getLocation().getDirection().multiply(-0.5).setY(0.4));
                }
            }
        }
    }
Implementation of {@link NpcFactory} using Citizens.
helper/src/main/java/me/lucko/helper/npc/CitizensNpcFactory.java