Compare commits

...
3 Commits
Author SHA1 Message Date
Hiroku e01bc2eeab Merge branch 'nickname_invalid_format' into '1.4.0'
Resolves a bug in the format in which the nickname is saved in JSON.

See merge request cable-mc/cobblemon!797
2023-11-26 23:19:50 +00:00
Pedro Souza f6f3070b8e changelog 2023-11-26 20:18:37 -03:00
Pedro Souza 0f2301e668 Resolved nickname invalid format bug 2023-11-26 12:24:54 -03:00
2 changed files with 3 additions and 2 deletions
+1
View File
@@ -797,6 +797,7 @@
- Fixed Magnitude battle messages.
- Moves that are disabled or out of PP now show transparently in the battle GUI instead of being hidden completely.
- Statuses like sleep and frozen no longer last forever if it was carried over from a previous battle.
- Fixed a formatting error that affected Pokemon nicknames when the storage type is JSON.
### Localization
- Added species, ability, and move translations for `ko_ko`, `jp_jp`, `fr_fr`, `es_es`, `it_it`, and `zh_cn`.
@@ -753,7 +753,7 @@ open class Pokemon : ShowdownIdentifiable {
json.addProperty(DataKeys.POKEMON_LAST_SAVED_VERSION, Cobblemon.VERSION)
json.addProperty(DataKeys.POKEMON_UUID, uuid.toString())
json.addProperty(DataKeys.POKEMON_SPECIES_IDENTIFIER, species.resourceIdentifier.toString())
nickname?.let { json.addProperty(DataKeys.POKEMON_NICKNAME, Text.Serializer.toJson(it)) }
nickname?.let { json.add(DataKeys.POKEMON_NICKNAME, Text.Serializer.toJsonTree(it)) }
json.addProperty(DataKeys.POKEMON_FORM_ID, form.formOnlyShowdownId())
json.addProperty(DataKeys.POKEMON_EXPERIENCE, experience)
json.addProperty(DataKeys.POKEMON_LEVEL, level)
@@ -803,7 +803,7 @@ open class Pokemon : ShowdownIdentifiable {
} catch (e: InvalidIdentifierException) {
throw IllegalStateException("Failed to deserialize a species identifier")
}
nickname = json.get(DataKeys.POKEMON_NICKNAME)?.asString?.takeIf { it.isNotBlank() }?.let { Text.Serializer.fromJson(it) }
nickname = json.get(DataKeys.POKEMON_NICKNAME)?.let { Text.Serializer.fromJson(it) }
form = species.forms.find { it.formOnlyShowdownId() == json.get(DataKeys.POKEMON_FORM_ID).asString } ?: species.standardForm
level = json.get(DataKeys.POKEMON_LEVEL).asInt
experience = json.get(DataKeys.POKEMON_EXPERIENCE).asInt.takeIf { experienceGroup.getLevel(it) == level } ?: experienceGroup.getExperience(level)