nulli0n / ExcellentEnchants-spigot

GNU General Public License v3.0
37 stars 31 forks source link

Enchantment levels do not follow client translations. #103

Closed flerouwu closed 2 months ago

flerouwu commented 4 months ago

Issue

ExcellentEnchants manually maps the enchantment level to the corresponding roman numeral, without using the client's translations. This leads to issues where players wish to use different translations for the associated enchantment level.

Additionally, I am attempting to use this plugin on a server with a custom resource pack that changes the enchantment levels to custom unicode characters that are then mapped to custom textures.

For an example, see the screenshot below. image

Solution

This can be solved by instead using translation keys for the enchantment level. These keys are enchantment.level.<level> (e.g. enchantment.level.3).

While I'm unsure if the Bukkit API has a way of doing this, you can achieve this with either raw JSON tags or via Adventure.

Adventure Component API

While Adventure has first-class support for Paper, the documentation lists ways to incorporate the API on a Bukkit / Spigot server here.

Component itemName = Component.empty()
    .append(Component.text("Double Strike"))
    .appendSpace()
    .append(Component.translatable("enchantment.level.2", /* Fallback: */ "II"))

Raw JSON

I'm unsure if you can send custom JSON for item names via Bukkit. The Adventure APIs would probably be a better choice.

extra[0].fallback can be replaced with the current roman numeral system, to be used as a fallback if the translation key doesn't exist.

{
  "text": "Double Strike ",
  "extra": [
    {
      "type": "translatable",
      "translate": "enchantment.level.2",
      "fallback": "II"
    }
  ]
}
nulli0n commented 4 months ago

ExcellentEnchants is built under Spigot. This is not possible currently to use Translation Components in item's lore. We're waiting for Spigot API changes that allows doing that.

flerouwu commented 4 months ago

The link that I specified above (https://docs.advntr.dev/platform/bukkit.html) shows how you are able to implement Adventure on Bukkit.

nulli0n commented 4 months ago

I already have my own implementation done and awaiting for the Spigot API updates that allows to use it without NMS. Not gonna depend on adventure.

nulli0n commented 2 months ago

Not a thing for 1.21+ anymore (fixed by the game itself).