Skip to content

Commit 0d5e80e

Browse files
aschlosserGrover-c13
authored andcommitted
Added request to add modifiers to forts, for example a lure-module on a pokestop (#217)
* implemented request to add fort modifier * added @throws to javadoc for addModifier in Pokestop.java
1 parent 612e3af commit 0d5e80e

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/main/java/com/pokegoapi/api/map/fort/Pokestop.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,13 @@
1515

1616
package com.pokegoapi.api.map.fort;
1717

18+
import POGOProtos.Inventory.Item.ItemIdOuterClass;
1819
import POGOProtos.Map.Fort.FortDataOuterClass;
20+
import POGOProtos.Networking.Requests.Messages.AddFortModifierMessageOuterClass.AddFortModifierMessage;
1921
import POGOProtos.Networking.Requests.Messages.FortDetailsMessageOuterClass.FortDetailsMessage;
2022
import POGOProtos.Networking.Requests.Messages.FortSearchMessageOuterClass.FortSearchMessage;
2123
import POGOProtos.Networking.Requests.RequestTypeOuterClass;
24+
import POGOProtos.Networking.Responses.AddFortModifierResponseOuterClass;
2225
import POGOProtos.Networking.Responses.FortDetailsResponseOuterClass;
2326
import POGOProtos.Networking.Responses.FortSearchResponseOuterClass;
2427
import com.google.protobuf.InvalidProtocolBufferException;
@@ -126,6 +129,31 @@ public PokestopLootResult loot() throws LoginFailedException, RemoteServerExcept
126129
return new PokestopLootResult(response);
127130
}
128131

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+
129157
/**
130158
* Get more detailed information about a pokestop.
131159
*

0 commit comments

Comments
 (0)