Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
2.3 kB
5
Indexable
Never
package com.trexmine.chat.listeners;

import com.trexmine.chat.configuration.Configuration;
import com.trexmine.chat.utils.Utils;
import com.trexmine.chat.utils.VanishCheck;
import me.clip.placeholderapi.PlaceholderAPI;
import net.luckperms.api.LuckPerms;
import net.luckperms.api.cacheddata.CachedMetaData;
import net.luckperms.api.model.group.Group;
import net.luckperms.api.model.user.User;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;

import java.util.Collection;

public final class AsyncPlayerChatListener implements Listener {
    @EventHandler(priority = EventPriority.LOWEST)
    public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {

        Player player = event.getPlayer();
        String message = event.getMessage();

        if (player.hasPermission("chat.emoji")) {
            String lastColor = ChatColor.getLastColors(message);

            if (lastColor.isEmpty()) {
                lastColor = Configuration.DEFAULT_MESSAGE_COLOR;
            }

            message = Configuration.DEFAULT_MESSAGE_COLOR + message
                    .replace("<3", ChatColor.RED + "❤" + lastColor)
                    .replace("o/", ChatColor.LIGHT_PURPLE + "( ゚◡゚)/" + lastColor)
                    .replace("O_O", ChatColor.BLUE + "◎" + ChatColor.YELLOW + "_" + ChatColor.BLUE + "◎" + lastColor)
                    .replace("h/", ChatColor.GOLD + "ヽ(^◇^*)/" + lastColor)
                    .replace(":gg:", ChatColor.GOLD + "" + ChatColor.BOLD + "GG" + lastColor)
                    .replace("^-^", ChatColor.GREEN + "^-^" + lastColor)
                    .replace(":gimme:", ChatColor.AQUA + "༼つ ◕_◕ ༽つ" + lastColor)
                    .replace(":shrug:", ChatColor.YELLOW + "¯\\_(ツ)_/¯" + lastColor)
                    .replace(":tableflip:", ChatColor.RED + "(╯°□°)╯" + ChatColor.GRAY + "︵ ┻━┻" + lastColor)
                    .replace(":yey:", ChatColor.GREEN + "ヽ (◕◡◕) ノ" + lastColor);

            event.setMessage(message);
        }
    }
}
Leave a Comment