@@ -84,9 +84,9 @@ public class MMState {
8484 .create ();
8585
8686 @ SerializedName ("jv" )
87- private int jsonVersion = 0 ;
87+ private int jsonVersion = LASTEST_JSON_VERSION ;
8888 @ SerializedName ("dv" )
89- private int dataVersion = 0 ;
89+ private int dataVersion = LASTEST_DATA_VERSION ;
9090
9191 public MMConfig config = new MMConfig ();
9292
@@ -138,8 +138,11 @@ public MMState clone() {
138138 return copy ;
139139 }
140140
141+ private static final int LASTEST_JSON_VERSION = 2 ;
142+ private static final int LASTEST_DATA_VERSION = 0 ;
143+
141144 private static void migrateJson (JsonObject obj ) {
142- int version = obj .has ("jv" ) ? obj .get ("jv" ).getAsInt () : 2 ;
145+ int version = obj .has ("jv" ) ? obj .get ("jv" ).getAsInt () : LASTEST_JSON_VERSION ;
143146
144147 if (version == 0 ) {
145148 if (obj .get ("config" ) instanceof JsonObject config ) {
@@ -157,11 +160,13 @@ private static void migrateJson(JsonObject obj) {
157160
158161 if (version == 1 ) {
159162 try {
160- // Load with the default encoder
161- BitSet bitSet = new Gson ().fromJson (obj .get ("installedUpgrades" ), BitSet .class );
163+ if (obj .get ("installedUpgrades" ) != null && obj .get ("installedUpgrades" ).isJsonArray ()) {
164+ // Load with the default encoder
165+ BitSet bitSet = new Gson ().fromJson (obj .get ("installedUpgrades" ), BitSet .class );
162166
163- // Save with the new encoder
164- obj .add ("installedUpgrades" , GSON .toJsonTree (bitSet ));
167+ // Save with the new encoder
168+ obj .add ("installedUpgrades" , GSON .toJsonTree (bitSet ));
169+ }
165170 } catch (Throwable t ) {
166171 MMMod .LOG .error ("Could not migrate installedUpgrades: your MM upgrades may have been deleted." , t );
167172 }
0 commit comments