From 562781fe82e4bdd362950b91699674e28c1050b8 Mon Sep 17 00:00:00 2001 From: Jasper Abbink Date: Sun, 24 Jul 2016 14:14:01 +0200 Subject: [PATCH] find Pokemon by ID update inventory after hatching eggs add missing license --- .../com/pokegoapi/api/inventory/Hatchery.java | 1 + .../com/pokegoapi/api/inventory/PokeBank.java | 15 +++++++++++++++ .../com/pokegoapi/api/pokemon/HatchedEgg.java | 15 +++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/src/main/java/com/pokegoapi/api/inventory/Hatchery.java b/src/main/java/com/pokegoapi/api/inventory/Hatchery.java index 19236139..ba7f43e8 100644 --- a/src/main/java/com/pokegoapi/api/inventory/Hatchery.java +++ b/src/main/java/com/pokegoapi/api/inventory/Hatchery.java @@ -66,6 +66,7 @@ public List queryHatchedEggs() throws RemoteServerException, LoginFa } catch (InvalidProtocolBufferException e) { throw new RemoteServerException(e); } + instance.getInventories().updateInventories(); List eggs = new ArrayList(); for (int i = 0; i < response.getPokemonIdCount(); i++) { eggs.add(new HatchedEgg(response.getPokemonId(i), diff --git a/src/main/java/com/pokegoapi/api/inventory/PokeBank.java b/src/main/java/com/pokegoapi/api/inventory/PokeBank.java index fe40c054..9e3fa2b8 100644 --- a/src/main/java/com/pokegoapi/api/inventory/PokeBank.java +++ b/src/main/java/com/pokegoapi/api/inventory/PokeBank.java @@ -82,4 +82,19 @@ public boolean test(Pokemon pokemn) { } }).collect(Collectors.toList()); } + + /** + * Get a pokemon by id. + * + * @param id the id + * @return the pokemon + */ + public Pokemon getPokemonById(final Long id) { + for (Pokemon pokemon : pokemons) { + if (pokemon.getId() == id) { + return pokemon; + } + } + return null; + } } diff --git a/src/main/java/com/pokegoapi/api/pokemon/HatchedEgg.java b/src/main/java/com/pokegoapi/api/pokemon/HatchedEgg.java index 396a4033..afe8f000 100644 --- a/src/main/java/com/pokegoapi/api/pokemon/HatchedEgg.java +++ b/src/main/java/com/pokegoapi/api/pokemon/HatchedEgg.java @@ -1,3 +1,18 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + package com.pokegoapi.api.pokemon; import lombok.AllArgsConstructor;