package io.github.lasercar.simplemention;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Collection;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class SimpleMention extends JavaPlugin implements Listener {

    //init

    String format_mention;
    String format_default;

    public void onEnable() {
        saveDefaultConfig();
        getConfig().options().copyDefaults(true);
        saveConfig();

        format_mention = getConfig().getString("format-mention");
        format_default = getConfig().getString("format-default");

        getServer().getPluginManager().registerEvents(this, this);
    }

    //events

    @EventHandler
    public void onChat(AsyncPlayerChatEvent event) {
        String message = event.getMessage();

        if (message.contains("@")) {
            Player player = event.getPlayer();
            Collection onlinePlayers = Bukkit.getOnlinePlayers();

            Pattern pattern = Pattern.compile("(@\\w+)");
            //make this^ looser and move checking to later if adding @/group formats
            Matcher matcher = pattern.matcher(message);

            while (matcher.find()) {
                getLogger().info(matcher.group(1));
            }

            //for @ matches, replace and ping

//            event.setMessage(modifiedMessage);
        }
    }

}

package io.github.lasercar.simplemention;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class SimpleMention extends JavaPlugin implements Listener {

    //init

    String formatMention;
    String formatDefault;

    public void onEnable() {
        saveDefaultConfig();
        getConfig().options().copyDefaults(true);
        saveConfig();

        formatMention = getConfig().getString("format-mention");
        formatDefault = getConfig().getString("format-default");

        getServer().getPluginManager().registerEvents(this, this);
    }

    //events

    @EventHandler
    public void onChat(AsyncPlayerChatEvent event) {
        String message = event.getMessage();
        StringBuffer messageBuffer = new StringBuffer();

        if (message.contains("@")) {
            Player player = event.getPlayer();
            Collection players = Bukkit.getOnlinePlayers();

            Pattern pattern = Pattern.compile("(@\\w+)");
            Matcher matcher = pattern.matcher(message);

            while (matcher.find()) {
                String match = matcher.group(1);

                Collection found = players.stream().filter(p -> p.getPlayerListName().contains(match) || p.getDisplayName().contains(match));

                //TODO: partial matching of display name and username
                //TODO: only highlight mentions if found (prefix formatMention and suffix formatDefault)

                //TODO: ping matched players with sound
            }

//            event.setMessage(messageBuffer.toString());
        }
    }

}

Add WIP player filtering by match