@EventHandler(ignoreCancelled = true)
public void onPlayerJoin(PlayerJoinEvent event) {
Player player=event.getPlayer();
Entity entity=player.getWorld().spawnEntity(player.getLocation(), org.bukkit.entity.EntityType.VILLAGER);
entity.customName(Component.text(ChatColor.GOLD+"villager with custom name"));
entity.setCustomNameVisible(true);
}