use of POGOProtos.Settings.Master.ItemSettingsOuterClass.ItemSettings in project PokeGOAPI-Java by Grover-c13.
the class PokemonMeta method update.
/**
* Updates the PokemonMeta from the response to DownloadItemTemplatesResponse and caches it
*
* @param data the data from the response
* @param write if this should write the data to the cache
* @throws IOException if writing fails
*/
public static void update(ByteString data, boolean write) throws IOException {
DownloadItemTemplatesResponse templatesResponse = DownloadItemTemplatesResponse.parseFrom(data);
if (write) {
data.writeTo(new FileOutputStream(Utils.createTempFile("templates")));
}
List<ItemTemplate> templates = templatesResponse.getItemTemplatesList();
PokemonMeta.templates.clear();
PokemonMeta.templates.addAll(templates);
for (ItemTemplate template : templates) {
if (template.hasPokemonSettings()) {
PokemonSettings pokemonSettings = template.getPokemonSettings();
PokemonMeta.pokemonSettings.put(pokemonSettings.getPokemonId(), pokemonSettings);
} else if (template.hasMoveSettings()) {
MoveSettings moveSettings = template.getMoveSettings();
PokemonMeta.moveSettings.put(moveSettings.getMovementId(), moveSettings);
} else if (template.hasBadgeSettings()) {
BadgeSettings badgeSettings = template.getBadgeSettings();
PokemonMeta.badgeSettings.put(badgeSettings.getBadgeType(), badgeSettings);
} else if (template.hasItemSettings()) {
ItemSettings itemSettings = template.getItemSettings();
PokemonMeta.itemSettings.put(itemSettings.getItemId(), itemSettings);
} else if (template.hasBattleSettings()) {
battleSettings = template.getBattleSettings();
} else if (template.hasPokemonUpgrades()) {
upgradeSettings = template.getPokemonUpgrades();
}
}
Evolutions.initialize(templates);
PokemonCpUtils.initialize(templates);
}
Aggregations