package com.alttd.chat.handlers; import com.alttd.chat.VelocityChat; import com.alttd.chat.config.Config; import com.alttd.chat.managers.RegexManager; import com.alttd.chat.util.Utility; import com.velocitypowered.api.command.CommandSource; import com.velocitypowered.api.proxy.Player; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.MiniMessage; import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import java.util.HashMap; import java.util.Map; public class ChatHandler { public void privateMessage(CommandSource commandSource, Player recipient, String message) { // todo get the chatUserinstance of both players and or console - @teri should console be able to /msg? String senderName; String receiverName; if (commandSource instanceof Player) { Player sender = (Player) commandSource; senderName = sender.getUsername(); //plugin.getChatHandler().getChatPlayer(sender.getUniqueId()).setReplyTarget(event.getRecipient().getUniqueId()); // TODO this needs to be cleaner } else { senderName = Config.CONSOLENAME; } receiverName = recipient.getUsername(); MiniMessage miniMessage = MiniMessage.get(); message = Utility.parseColors(message); if(!commandSource.hasPermission("chat.format")) // Todo PR fix for '<3' to minimessage message = miniMessage.stripTokens(message); message = RegexManager.replaceText(message); // this filters the message TODO should staff be able to bypass filters? // List