Translation in sponge 8.0

In sponge 7.0 I can get ItemStack Translation name by this code.

ItemStack item;
item.getTranslation().get();

but in sponge 8.0, I couldn’t find the getTranslation method.

How can I get Translation in sponge 8.0 ?

Please help me.

This comes under the component library (new text library)

I believe you can do

Component component = item.asComponent();
if(component instanceof TranslatableComponent){
  TranslatableComponent translatable = (TranslatableComponent) component;
  //text is translatable
}

You can read more here

https://jd.adventure.kyori.net/api/4.9.3/net/kyori/adventure/text/TranslatableComponent.html

1 Like

Thank you so much!