Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Added request to add modifiers to forts, for example a lure-module on a pokestop #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/main/java/com/pokegoapi/api/map/fort/Pokestop.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@

package com.pokegoapi.api.map.fort;

import POGOProtos.Inventory.Item.ItemIdOuterClass;
import POGOProtos.Map.Fort.FortDataOuterClass;
import POGOProtos.Networking.Requests.Messages.AddFortModifierMessageOuterClass.AddFortModifierMessage;
import POGOProtos.Networking.Requests.Messages.FortDetailsMessageOuterClass.FortDetailsMessage;
import POGOProtos.Networking.Requests.Messages.FortSearchMessageOuterClass.FortSearchMessage;
import POGOProtos.Networking.Requests.RequestTypeOuterClass;
import POGOProtos.Networking.Responses.AddFortModifierResponseOuterClass;
import POGOProtos.Networking.Responses.FortDetailsResponseOuterClass;
import POGOProtos.Networking.Responses.FortSearchResponseOuterClass;
import com.google.protobuf.InvalidProtocolBufferException;
Expand Down Expand Up @@ -126,6 +129,31 @@ public PokestopLootResult loot() throws LoginFailedException, RemoteServerExcept
return new PokestopLootResult(response);
}

/**
* Adds a modifier to this pokestop. (i.e. add a lure module)
*
* @param item the modifier to add to this pokestop
* @throws LoginFailedException if login failed
* @throws RemoteServerException if the server failed to respond or the modifier could not be added to this pokestop
*/
Copy link
Contributor

@Jari27 Jari27 Jul 25, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add @throws ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops. Fixed it.

public void addModifier(ItemIdOuterClass.ItemId item) throws LoginFailedException, RemoteServerException {
AddFortModifierMessage msg = AddFortModifierMessage.newBuilder()
.setModifierType(item)
.setFortId(getId())
.setPlayerLatitude(api.getLatitude())
.setPlayerLongitude(api.getLongitude())
.build();
ServerRequest serverRequest = new ServerRequest(RequestTypeOuterClass.RequestType.ADD_FORT_MODIFIER, msg);
api.getRequestHandler().sendServerRequests(serverRequest);
AddFortModifierResponseOuterClass.AddFortModifierResponse response;
try {
//sadly the server response does not contain any information to verify if the request was successful
response = AddFortModifierResponseOuterClass.AddFortModifierResponse.parseFrom(serverRequest.getData());
} catch (InvalidProtocolBufferException e) {
throw new RemoteServerException(e);
}
}

/**
* Get more detailed information about a pokestop.
*
Expand Down