Follow up to https://hub.spigotmc.org/jira/browse/SPIGOT-7622. As of latest 1.20.5 spigot build, we no longer throw an exception but the sign does not actually get changed. Same code does change the sign on 1.20.4.
Here is the code used to obtain the sign object from PlayerInteractEvent:
if (currTranslator.getTranslatingSign() && event.getClickedBlock() != null && event.getClickedBlock().getType().name().contains("SIGN") && checkInventoryHand(event) && event.getAction() == Action.RIGHT_CLICK_BLOCK) { /* Start sign translation */ Sign currentSign = (Sign) event.getClickedBlock().getState(); ...
This seems to work as expected on 1.20.4 and 1.20.5; if the sign was null I don't call sendSignChange().
After getting the sign object, I use the following code once again:
// Sign currentSign = (Sign) event.getClickedBlock().getState(); (above) String[] signText = currentSign.getLines(); String[] changedSignText = new String[signText.length]; Location currLoc = currentSign.getLocation(); boolean textLimit = false; /* Send message */ refs.sendFancyMsg("wwcSignTranslateStart", "", "&d&l", event.getPlayer()); /* Translate each line of sign */ for (int i = 0; i < changedSignText.length; i++) { String eaLine = refs.translateText(signText[i], event.getPlayer()); changedSignText[i] = eaLine; } event.getPlayer().sendSignChange(currLoc, changedSignText);
The rest of the code remains unchanged. My plugin successfully sets the changedSignText obj (and this code works on a downgrade.)