Phoenix616 / MineDown

A MarkDown inspired markup library for Minecraft chat components
https://wiki.phoenix616.dev/library/minedown/
MIT License
296 stars 21 forks source link

HEX coloring doesn't work correctly. #6

Closed CDFN closed 4 years ago

CDFN commented 4 years ago

Used Version

    compileOnly("net.kyori:adventure-api:4.0.0-SNAPSHOT")
    compileOnly("net.kyori:adventure-text-serializer-gson:4.0.0-SNAPSHOT")
    compileOnly("net.kyori:adventure-platform-bukkit:4.0.0-SNAPSHOT")
    compileOnly("de.themoep:minedown-adventure:1.6.1-SNAPSHOT")

Config

Code

class PlayerChatListener(override val plugin: ChatPlugin) : KListener<ChatPlugin> {
    private val audience = BukkitAudiences.create(plugin)
    var chatServiceProvider = plugin.server.servicesManager.getRegistration(Chat::class.java) as RegisteredServiceProvider<Chat>

    init {
        event<AsyncPlayerChatEvent> {
            this.recipients.clear()
            var component = MineDown.parse("[%prefix%%displayname% &8» &7%message%](&7Click to DM! suggest_command=/msg %name% )")
            val messageComponent = MineDown("")

            if (!player.hasPermission("chat.color")) {
                messageComponent.parser().disable(MineDownParser.Option.LEGACY_COLORS)
            }

            if (!player.hasPermission("chat.simple")) {
                messageComponent.parser().disable(MineDownParser.Option.SIMPLE_FORMATTING)
            }

            if (!player.hasPermission("chat.advanced")) {
                messageComponent.parser().disable(MineDownParser.Option.ADVANCED_FORMATTING)
            }

            component = Replacer.replaceIn(component, "message", messageComponent.parser().parse(this.message).asComponent())
            component = Replacer.replaceIn(component, "prefix", MineDown.parse(chatServiceProvider.provider.getPlayerPrefix(this.player)))
            component = Replacer.replaceIn(
                    component,
                    "displayname", this.player.displayName,
                    "name", this.player.name,
            )
            audience.all().sendMessage(component)

        }
    }
}

Environment description

Ubuntu 20.04, API accessed using Kotlin. Server version paper-204.

Full Log

[00:14:57 INFO]: ROOT CDFN » &#6662
[00:14:58 INFO]: <CDFN> &#666&12
[00:15:23 INFO]: ROOT CDFN » &#666&test_message
[00:15:23 INFO]: <CDFN> &#666&test_message
[00:15:55 INFO]: ROOT CDFN » test_message
[00:15:56 INFO]: <CDFN> &gold&test_message
[00:21:37 INFO]: ROOT CDFN » &#ff00ff&text
[00:21:37 INFO]: <CDFN> &#ff00ff&Text

What other programs/plugins are you running?

image Only OneBlock-chat does stuff with MineDown, OneBlock-fancyresources has some replacements using Adventure in it.

What is happening?

When using &#666&test_message syntax, message doesn't get colored. It happens only with rgb, &gold&test_message syntax works correctly. Full HEX syntax (#ff00ff&Text) doesn't work either.

What did you expect to happen?

&#666&test_message displays as test_message with #666 HEX color on it.

Additional context

&#666&test_message: image &gold&test_message: image