[Solved] Get the raw text of a sign line

Hello.
I’m trying to get the text of the first line of a sign.

My Code (clickedEntity is the Sign-TileEntity):

Optional<SignData> data = clickedEntity.getOrCreate(SignData.class);
if(data.isPresent()){
      Text firstline = data.get().getLine(0);
      log.info(firstline.toString());
}

This prints following:

Literal{Text{color=org.spongepowered.api.text.format.TextColors$1@777afffb, style=TextStyle{bold=Optional.absent(), italic=Optional.absent(), underline=Optional.absent(), strikethrough=Optional.absent(), obfuscated=Optional.absent()}, children=, clickAction=Optional.absent(), hoverAction=Optional.absent(), shiftClickAction=Optional.absent()}, content=Test123}

How can i get the content (“Test123”) only? There are functions like getColor or getStyle, but something like getContent is missing.

https://github.com/SpongePowered/SpongeAPI/blob/master/src/main/java/org/spongepowered/api/text/Texts.java#L404

1 Like

What @Faithcaio said:

Texts.toPlain(firstline);
1 Like