Skip to content

Implement default PlayerDisplayNameProvider API#803

Draft
TechnicJelle wants to merge 1 commit into
BlueMap-Minecraft:masterfrom
TechnicJelle:master
Draft

Implement default PlayerDisplayNameProvider API#803
TechnicJelle wants to merge 1 commit into
BlueMap-Minecraft:masterfrom
TechnicJelle:master

Conversation

@TechnicJelle
Copy link
Copy Markdown
Member

@TechnicJelle TechnicJelle commented May 12, 2026

Implemented a default for the API added in BlueMap-Minecraft/BlueMapAPI#9

I'm not all too happy about it all yet, especially the locations of some things and what I had to pass into other places.
Also, the default implementation currently kind of sucks.

I'd be happy to get feedback on this!

Screenshots of this working image image image
Addon plugin code
package com.TechnicJelle.blueMapCustomPlayerNames;

import de.bluecolored.bluemap.api.BlueMapAPI;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.TextComponent;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.function.Consumer;

public final class BlueMapCustomPlayerNames extends JavaPlugin {

    @Override
    public void onEnable() {
        BlueMapAPI.onEnable(bluemapOnEnable);
    }

    Consumer<BlueMapAPI> bluemapOnEnable = (BlueMapAPI api) -> {
        api.getPlugin().setPlayerNameProvider(playerUUID -> {
            Player player = getServer().getPlayer(playerUUID);
            if (player == null) return playerUUID.toString();

            Component displayName = player.displayName();
            if (displayName instanceof TextComponent textComponent)
                return "<span style=\"color: blue;\">" + textComponent.content() + "</span>";

            return playerUUID.toString();
        });
    };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant