Solved Get the title of an advancement

MJDawson

New member
Dec 21, 2022
4
0
1
Hi,
So I'm trying to get the title of of the enchantment.
Code:
Java:
    public void onPlayerAchievement(PlayerAdvancementDoneEvent event) throws Exception{
       
        String advancementName = event.getAdvancement().toString();
       
        //Do some things with advancementName...

    }

But whatever I try just gives me something like this:
Code:
TranslatableComponentImpl{key="chat.square_brackets", args=[TranslatableComponentImpl{key="advancements.adventure.adventuring_time.title", args=[], style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=null, clickEvent=null, hoverEvent=HoverEvent{action=show_text, value=TranslatableComponentImpl{key="advancements.adventure.adventuring_time.title", args=[], style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=NamedTextColor{name="dark_purple", value="#aa00aa"}, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[TextComponentImpl{content="\n", style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=null, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}, TranslatableComponentImpl{key="advancements.adventure.adventuring_time.description", args=[], style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=null, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}]}}, insertion=null, font=null}, children=[]}], style=StyleImpl{obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, color=NamedTextColor{name="dark_purple", value="#aa00aa"}, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}
OR
Code:
org.bukkit.craftbukkit.v1_19_R1.advancement.CraftAdvancement@6f87bef
OR
Code:
PaperAdvancementDisplay[handle=net.minecraft.advancements.AdvancementDisplay@3579e40e]

And more random things that I don't want.
Everything that I have seen online has not worked for paper.
Any idea what I need to do:
 
Version Output
Paper version git-Paper-307 (MC: 1.19.2)
Last edited:

Machine Maker

Paper Developer
Staff member
Dec 17, 2021
132
6
19
18
California
What do you want with the advancement name? The advancement name is a Translatable component which is resolved on the client. Minecraft supports a ton of languages so the “name” isn’t really known on the server. If you are just sending the advancement name somewhere else on the server, you should just use the translatable component, but otherwise you’re going to have to be more specific about what you want to do with it.
 

MJDawson

New member
Dec 21, 2022
4
0
1
What do you want with the advancement name? The advancement name is a Translatable component which is resolved on the client. Minecraft supports a ton of languages so the “name” isn’t really known on the server. If you are just sending the advancement name somewhere else on the server, you should just use the translatable component, but otherwise you’re going to have to be more specific about what you want to do with it.
I want to get the title like, bullseye or Monster Hunter.
 

MJDawson

New member
Dec 21, 2022
4
0
1
That is no more information than I had before. What do you want to do with the title? That will determine what the best solution is.
Oh right. I'm sending using to send through a discord bot This was the rest of my code in my event:


Java:
EmbedBuilder embed = new EmbedBuilder();
embed.setDescription(advancementName);
embed.setColor(Color.orange);
jda.getTextChannelById(channelId)
        .sendMessage("").setEmbeds(embed.build()).queue();