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.event.player.PlayerChatTabCompleteEvent;

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

public class Events implements Listener {

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

        if (MessageParser.hasMentions(message)) {

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

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

                Player[] playersMatched = PlayerMatcher.findAllByName(mention);

                if (playersMatched.length > 0) {
                    matcher.appendReplacement(messageBuffer, MessageParser.highlightMention(mention));

                    SoundManager.pingPlayers(playersMatched);
                }
            }
            matcher.appendTail(messageBuffer);

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

    @EventHandler
    public void onTabComplete(PlayerChatTabCompleteEvent event) {
        Bukkit.getLogger().info(event.toString());
    }

}

@@ -1358,45 +1358,331 @@
 ) %7B%0A
-        Bukkit.getLogger().info(event
+//        if (event.getLastToken().equals(%22@%22)) %7B%0A//            event.getTabCompletions().push(Bukkit.getOnlinePlayers());%0A//        %7D%0A%0A        //DEBUG%0A        Bukkit.getLogger().info(event.getTabCompletions().toString());%0A        event.getTabCompletions().clear();%0A        Bukkit.getLogger().info(event.getTabCompletions()
 .toS

Test changing tab complete list