T

แชทของผู้เล่นที่มีหัวสกินของผู้เล่นอยู่ด้านหน้า ใช้ได้ทั้ง java และ bedrock รองรับ สีทุกสีของ minecraft และ PlaceholderAPI

Kodari AI
KodariJun 8 at 1:25 pm 13
PlayerHeadChat
A Paper chat plugin that displays the player's skin head (via hover) in front of every chat message. Supports Java and Bedrock players (Floodgate), all Minecraft color codes (&-legacy and MiniMessage), PlaceholderAPI for prefix/suffix, and fully configurable chat formats. Player heads are pre-cached on join for async-safe rendering. Click the name to auto-fill /msg, hover for the skull preview.

Plan:

  1. build.gradle + plugin.yml + config.yml

  2. PlayerHeadChat.java — main class, hooks PAPI + Floodgate

  3. ConfigManager.java — config wrapper

  4. FloodgateHook.java — safe Floodgate wrapper

  5. MessageFormatter.java — builds Adventure components with skull hover

  6. ChatListener.java — AsyncChatEvent handler

  7. ConnectionListener.java — pre-caches skulls on join


How it works:

Feature
Detail
Head in chat
A
◈
icon before the name; hover it to see the player’s 3D skin head (Java only)
Bedrock support
Floodgate detection — Bedrock players receive a plain-text format without unsupported hover/click components
All colors
&
legacy codes supported for everyone; MiniMessage tags for OPs (
playerheadchat.miniMessage
)
PlaceholderAPI
Full PAPI support in
chat-format
— use
%luckperms_prefix%
,
%player_level%
, etc.
Click name
Click the player name to auto-suggest
/msg <player>
Skull cache
Skulls are pre-built on the main thread at join and cached, making the
AsyncChatEvent
handler fully thread-safe

Config keys to customise:

Plain Text
chat-format            — full format with PAPI + {player} + {message}
head-icon              — the icon shown before the name (default ◈)
head-tooltip-name-color — MiniMessage color for the name in the tooltip
click-to-message        — toggle /msg click behaviour
allow-color-in-message  — allow & codes in player messages
Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
Code
9 488
src/main/java/com/kodari/playerheadchat/PlayerHeadChat.java
package com.kodari.playerheadchat;

import com.kodari.playerheadchat.formatter.MessageFormatter;
import com.kodari.playerheadchat.hook.FloodgateHook;
import com.kodari.playerheadchat.listener.ChatListener;
import com.kodari.playerheadchat.listener.ConnectionListener;
import com.kodari.playerheadchat.manager.ConfigManager;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.java.JavaPlugin;

public final class PlayerHeadChat extends JavaPlugin {

    @Getter private static PlayerHeadChat instance;
    @Getter private ConfigManager configManager;
    @Getter private MessageFormatter messageFormatter;
    @Getter private FloodgateHook floodgateHook;

    @Override
    public void onEnable() {
        instance = this;
        saveDefaultConfig();

        configManager = new ConfigManager(this);

        floodgateHook = new FloodgateHook();
        floodgateHook.init(this);

        messageFormatter = new MessageFormatter(this);

        getServer().getPluginManager().registerEvents(new ChatListener(this), this);
        getServer().getPluginManager().registerEvents(new ConnectionListener(this), this);

        if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
            getLogger().info("PlaceholderAPI hooked successfully.");
        } else {
            getLogger().warning("PlaceholderAPI not found — placeholders will not be parsed.");
        }

        getLogger().info("PlayerHeadChat enabled.");
    }

    @Override
    public void onDisable() {
        messageFormatter.clearCache();
        getLogger().info("PlayerHeadChat disabled.");
    }

    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        if (args.length == 1 && args[0].equalsIgnoreCase("reload")) {
            if (!sender.hasPermission("playerheadchat.reload")) {
                sender.sendMessage("§cYou don't have permission to do that.");
                return true;
            }
            reloadConfig();
            configManager.reload();
            messageFormatter.clearCache();
            sender.sendMessage("§a[PlayerHeadChat] Config reloaded.");
            return true;
        }
        sender.sendMessage("§6[PlayerHeadChat] §fUsage: /phchat reload");
        return true;
    }
}