@@ -851,36 +851,38 @@ public void setSignText(@NotNull List<ComponentPackage> lines) {
851851 for (Sign sign : signs ) {
852852 if (this .plugin .getNbtapi () != null ) {
853853 NBTTileEntity tileSign = new NBTTileEntity (sign );
854- NBTList <String > messageNBTList = null ;
855- if (plugin .getGameVersion ().ordinal () >= GameVersion .v1_20_R1 .ordinal ()) {
856- NBTCompound frontNBTCompound = tileSign .getCompound ("front_text" );
857- if (frontNBTCompound == null ) {
858- // It should never run into there, but just in case
859- sign .getSide (Side .FRONT ).setLine (0 , "[Fix]" );
860- sign .update (true );
861- frontNBTCompound = tileSign .getCompound ("front_text" );
862- }
863- messageNBTList = frontNBTCompound .getStringList ("messages" );
864- }
865- for (int i = 0 ; i < lines .size (); i ++) {
866- try {
867- if (plugin .getGameVersion ().ordinal () >= GameVersion .v1_20_R1 .ordinal ()) {
868- if (messageNBTList != null ) {
869- messageNBTList .set (i , Util .componentsToJson (lines .get (i ).getComponents ()));
870- } else {
871- throw new IllegalStateException ("Sign NBT seems broken!" );
872- }
873- } else {
854+ try {
855+ if (plugin .getGameVersion ().ordinal () >= GameVersion .v1_20_R1 .ordinal ()) {
856+ NBTCompound frontNBTCompound = tileSign .getCompound ("front_text" );
857+ if (frontNBTCompound == null ) {
858+ // It should never run into there, but just in case
859+ sign .getSide (Side .FRONT ).setLine (0 , "[Fix]" );
860+ sign .update (true );
861+ frontNBTCompound = tileSign .getCompound ("front_text" );
862+ }
863+ if (frontNBTCompound == null ) {
864+ throw new IllegalStateException ("Sign NBT structure seems changed/broken! original dump:" + tileSign );
865+ }
866+ NBTList <String > messageNBTList = frontNBTCompound .getStringList ("messages" );
867+ if (messageNBTList == null ) {
868+ throw new IllegalStateException ("Sign NBT structure seems changed/broken! original dump:" + tileSign );
869+ }
870+ for (int i = 0 ; i < lines .size (); i ++) {
871+ messageNBTList .set (i , Util .componentsToJson (lines .get (i ).getComponents ()));
872+ }
873+ } else {
874+ for (int i = 0 ; i < lines .size (); i ++) {
874875 tileSign .setString ("Text" + (i + 1 ), Util .componentsToJson (lines .get (i ).getComponents ()));
875876 }
876- } catch (Exception e ) {
877- plugin .getLogger ().log (Level .WARNING , "NBTAPI support is broken, disable and fallback... (You can safely ignore this)" , e );
878- plugin .disableNBTAPI ();
879- Util .debugLog ("NBTAPI is broken, error: " + e .getMessage () + "\n stacktrace: \n " + Arrays .toString (e .getStackTrace ()));
880- //Reset it since we disable nbt api, text need to change
881- setSignText ();
882- return ;
883877 }
878+ sign .update (true );
879+ } catch (Exception e ) {
880+ plugin .getLogger ().log (Level .WARNING , "NBTAPI support is broken, disable and fallback... (You can safely ignore this)" , e );
881+ plugin .disableNBTAPI ();
882+ Util .debugLog ("NBTAPI is broken, error: " + e .getMessage () + "\n stacktrace: \n " + Arrays .toString (e .getStackTrace ()));
883+ //Reset it since we disable nbt api, text need to change
884+ setSignText ();
885+ return ;
884886 }
885887 } else {
886888 for (int i = 0 ; i < lines .size (); i ++) {
@@ -900,6 +902,7 @@ public void setSignText(@NotNull List<ComponentPackage> lines) {
900902 sign .update (true );
901903 plugin .getServer ().getPluginManager ().callEvent (new ShopSignUpdateEvent (this , sign ));
902904 }
905+
903906 }
904907
905908 /**
0 commit comments