SkytAsul / GlowingEntities

An API to easily make Minecraft entities glow. No dependencies, compatible 1.17 -> 1.21.
MIT License
68 stars 9 forks source link

Glowing changes the players nametag #10

Closed Nuckerr closed 1 year ago

Nuckerr commented 1 year ago

When I set a glow, it changes the player's nametag. How can I avoid this?

SkytAsul commented 1 year ago

Can you show me an example?

Nuckerr commented 1 year ago

https://imgur.com/0jmbDlc

The code looks like this:

glow.clearGlowing(player)
        team.players
            .filter { it.uniqueId != player.uniqueId }
            .filter { it.isOnline }
            .map { it.player!! }
            .filter { it.gameMode != GameMode.SPECTATOR }
            .forEach {
                val color = getColorTeamAsInt(getTeamId(team)!!)
                val textColor = TextColor.color(color)
                glow.setGlowing(it, player, NamedTextColor.nearestTo(textColor).toChatColor())
                glow.setGlowing(player, it, NamedTextColor.nearestTo(textColor).toChatColor())
            }

fun GlowingEntities.clearGlowing(entity: Entity) {
    Bukkit.getOnlinePlayers().forEach {
        unsetGlowing(entity, it)
        if(entity is Player) unsetGlowing(it, entity);
    }
}
SkytAsul commented 1 year ago

Ah yeah it's because GlowingEntities change the team to change the color (related to #5 and #9). To avoid that, set the "color" parameter of the "setGlowing" method to null: the player will now glow with its team color.