LuckPerms

LuckPerms

41.4k Downloads

Update me.lucko:adventure-api:4.0.0 to 4.1.1

Karlatemp opened this issue ยท 3 comments

commented

Description

LuckPerms using me.lucko:adventure-api:4.0.0, translatable components with no args will only render translated value.
All children of the translatable component lost.

> lp info
[LP] Running
.....

Reproduction steps

  1. run /lp info

Expected behaviour

print

[LP] Running LuckPerms vXXX by luck

Environment details

Any other relevant details

https://github.com/lucko/LuckPerms/blob/0ea0ce9d268dce264a5a58138dff978a86b45459/common/build.gradle#L5-L10

package misc

import me.lucko.luckperms.common.locale.TranslationManager
import net.kyori.adventure.key.Key
import net.kyori.adventure.text.Component.text
import net.kyori.adventure.text.Component.translatable
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer
import net.kyori.adventure.translation.GlobalTranslator
import net.kyori.adventure.translation.Translator
import java.text.MessageFormat
import java.util.*

// fun render(comp: Component) = GlobalTranslator.render(comp, Locale.getDefault())

fun main() {

    val comp = translatable().key(
        "test"
    ).append(text("FAQ"))
        .build()
    GlobalTranslator.get().addSource(object : Translator {
        val n = Key.key("test")
        override fun name(): Key = n

        override fun translate(key: String, locale: Locale): MessageFormat? {
            if (key == "test") return MessageFormat("test0")
            return null
        }
    })
    val translated = TranslationManager.render(comp)
    println(LegacyComponentSerializer.legacySection().serialize(translated))
    println(LegacyComponentSerializer.legacySection().serialize(comp))

    println("=============")

    println(GsonComponentSerializer.gson().serialize(translated))
    println(GsonComponentSerializer.gson().serialize(comp))

}
test0
extV
=============
{"text":"test0"}
{"translate":"test","extra":[{"text":"extV"}]}
commented

I am using this repo's latest commit. (or dev version?)

commented

This has already been fixed, you won't be able to reproduce it using the latest version: https://luckperms.net/

commented

The runtime dependency differs from the one used in the build.gradle file - the reason you are having this problem is because you are running using your IDE.

Try actually loading the built jar file on a server, you will see that it works correctly.