|
15 | 15 |
|
16 | 16 | package com.pokegoapi.api.map.fort; |
17 | 17 |
|
| 18 | +import POGOProtos.Inventory.Item.ItemIdOuterClass; |
18 | 19 | import POGOProtos.Map.Fort.FortDataOuterClass; |
| 20 | +import POGOProtos.Networking.Requests.Messages.AddFortModifierMessageOuterClass.AddFortModifierMessage; |
19 | 21 | import POGOProtos.Networking.Requests.Messages.FortDetailsMessageOuterClass.FortDetailsMessage; |
20 | 22 | import POGOProtos.Networking.Requests.Messages.FortSearchMessageOuterClass.FortSearchMessage; |
21 | 23 | import POGOProtos.Networking.Requests.RequestTypeOuterClass; |
| 24 | +import POGOProtos.Networking.Responses.AddFortModifierResponseOuterClass; |
22 | 25 | import POGOProtos.Networking.Responses.FortDetailsResponseOuterClass; |
23 | 26 | import POGOProtos.Networking.Responses.FortSearchResponseOuterClass; |
24 | 27 | import com.google.protobuf.InvalidProtocolBufferException; |
@@ -126,6 +129,31 @@ public PokestopLootResult loot() throws LoginFailedException, RemoteServerExcept |
126 | 129 | return new PokestopLootResult(response); |
127 | 130 | } |
128 | 131 |
|
| 132 | + /** |
| 133 | + * Adds a modifier to this pokestop. (i.e. add a lure module) |
| 134 | + * |
| 135 | + * @param item the modifier to add to this pokestop |
| 136 | + * @throws LoginFailedException if login failed |
| 137 | + * @throws RemoteServerException if the server failed to respond or the modifier could not be added to this pokestop |
| 138 | + */ |
| 139 | + public void addModifier(ItemIdOuterClass.ItemId item) throws LoginFailedException, RemoteServerException { |
| 140 | + AddFortModifierMessage msg = AddFortModifierMessage.newBuilder() |
| 141 | + .setModifierType(item) |
| 142 | + .setFortId(getId()) |
| 143 | + .setPlayerLatitude(api.getLatitude()) |
| 144 | + .setPlayerLongitude(api.getLongitude()) |
| 145 | + .build(); |
| 146 | + ServerRequest serverRequest = new ServerRequest(RequestTypeOuterClass.RequestType.ADD_FORT_MODIFIER, msg); |
| 147 | + api.getRequestHandler().sendServerRequests(serverRequest); |
| 148 | + AddFortModifierResponseOuterClass.AddFortModifierResponse response; |
| 149 | + try { |
| 150 | + //sadly the server response does not contain any information to verify if the request was successful |
| 151 | + response = AddFortModifierResponseOuterClass.AddFortModifierResponse.parseFrom(serverRequest.getData()); |
| 152 | + } catch (InvalidProtocolBufferException e) { |
| 153 | + throw new RemoteServerException(e); |
| 154 | + } |
| 155 | + } |
| 156 | + |
129 | 157 | /** |
130 | 158 | * Get more detailed information about a pokestop. |
131 | 159 | * |
|
0 commit comments