I am working on the migration of my bukkit plugin to Sponge and I am trying to modify the text of a sign.
I tried various solutions and read a lot of things in the forum but could not get the way to achieve this. The documentation is not up-to-date.
I think I must create a SignData with the new text and then update the BlockState using BlockState.with(SignData sign), and then update the location, but BlockState.with() does not accept a SignData.
public boolean setLines(TileEntity entity, Text line0, Text line1, Text line2, Text line3) {
SignData sign = entity.get(SignData.class).get();
if (line0!=null) sign = sign.set(sign.getValue(Keys.SIGN_LINES).get().set(0, line0));
if (line1!=null) sign = sign.set(sign.getValue(Keys.SIGN_LINES).get().set(1, line1));
if (line2!=null) sign = sign.set(sign.getValue(Keys.SIGN_LINES).get().set(2, line2));
if (line3!=null) sign = sign.set(sign.getValue(Keys.SIGN_LINES).get().set(3, line3));
entity.offer(sign);
return true;
}