Skip to content

Commit 580d752

Browse files
committed
Fix checkstyle
1 parent 94ba91e commit 580d752

2 files changed

Lines changed: 27 additions & 10 deletions

File tree

src/main/java/com/pokegoapi/api/map/pokemon/CatchablePokemon.java

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,17 +120,23 @@ public EncounterResult encounterPokemon() throws LoginFailedException, RemoteSer
120120
}
121121

122122
/**
123-
* Tries to catch a pokemon (will attempt to use a pokeball, if you have none will use greatball etc)
123+
* Tries to catch a pokemon (will attempt to use a pokeball, if you have none will use greatball etc).
124124
*
125125
* @return CatchResult
126126
* @throws LoginFailedException if failed to login
127127
* @throws RemoteServerException if the server failed to respond
128128
*/
129129
public CatchResult catchPokemon() throws LoginFailedException, RemoteServerException {
130130
Pokeball ball = Pokeball.POKEBALL;
131-
if (api.getBag().getItem(ItemIdOuterClass.ItemId.ITEM_POKE_BALL).getCount() == 0) ball = Pokeball.GREATBALL;
132-
if (api.getBag().getItem(ItemIdOuterClass.ItemId.ITEM_GREAT_BALL).getCount() == 0) ball = Pokeball.ULTRABALL;
133-
if (api.getBag().getItem(ItemIdOuterClass.ItemId.ITEM_ULTRA_BALL).getCount() == 0) ball = Pokeball.MASTERBALL;
131+
if (api.getBag().getItem(ItemIdOuterClass.ItemId.ITEM_POKE_BALL).getCount() == 0) {
132+
ball = Pokeball.GREATBALL;
133+
}
134+
if (api.getBag().getItem(ItemIdOuterClass.ItemId.ITEM_GREAT_BALL).getCount() == 0) {
135+
ball = Pokeball.ULTRABALL;
136+
}
137+
if (api.getBag().getItem(ItemIdOuterClass.ItemId.ITEM_ULTRA_BALL).getCount() == 0) {
138+
ball = Pokeball.MASTERBALL;
139+
}
134140
return catchPokemon(ball);
135141
}
136142

src/main/java/com/pokegoapi/main/RequestHandler.java

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,22 +59,30 @@ public RequestHandler(PokemonGo api, RequestEnvelopeOuterClass.RequestEnvelope.A
5959
apiEndpoint = ApiSettings.API_ENDPOINT;
6060
this.auth = auth;
6161
serverRequests = new ArrayList<>();
62-
// TODO: somehow fix it so people using the deprecated functions will still work, while not calling this deprecated stuff ourselves
62+
/* TODO: somehow fix it so people using the deprecated functions will still work,
63+
while not calling this deprecated stuff ourselves */
6364
resetBuilder();
6465
}
6566

66-
@Deprecated
6767
/**
6868
* Request.
6969
*
7070
* @param requestIn the request in
7171
*/
72+
@Deprecated
7273
public void request(ServerRequest requestIn) {
7374
hasRequests = true;
7475
serverRequests.add(requestIn);
7576
builder.addRequests(requestIn.getRequest());
7677
}
7778

79+
/**
80+
* Sends multiple ServerRequests in a thread safe manner.
81+
*
82+
* @param serverRequests list of ServerRequests to be sent
83+
* @throws RemoteServerException the remote server exception
84+
* @throws LoginFailedException the login failed exception
85+
*/
7886
public void sendServerRequests(ServerRequest... serverRequests) throws RemoteServerException, LoginFailedException {
7987
if (serverRequests.length == 0) {
8088
return;
@@ -106,8 +114,9 @@ public void sendServerRequests(ServerRequest... serverRequests) throws RemoteSer
106114
throw new RemoteServerException(e);
107115
}
108116

109-
if (response.code() != 200)
117+
if (response.code() != 200) {
110118
throw new RemoteServerException("Got a unexcepted http code : " + response.code());
119+
}
111120

112121
ResponseEnvelopeOuterClass.ResponseEnvelope responseEnvelop;
113122
try (InputStream content = response.body().byteStream()) {
@@ -133,25 +142,27 @@ public void sendServerRequests(ServerRequest... serverRequests) throws RemoteSer
133142
return;
134143
}
135144

136-
// map each reply to the numeric response, ie first response = first request and send back to the requests to handle.
145+
/* map each reply to the numeric response,
146+
ie first response = first request and send back to the requests to handle. */
137147
int count = 0;
138148
for (ByteString payload : responseEnvelop.getReturnsList()) {
139149
ServerRequest serverReq = serverRequests[count];
140-
// TODO: Probably all other payloads are garbage as well in this case, so might as well throw an exception and leave this loop
150+
/* TODO: Probably all other payloads are garbage as well in this case,
151+
so might as well throw an exception and leave this loop */
141152
if (payload != null) {
142153
serverReq.handleData(payload);
143154
}
144155
count++;
145156
}
146157
}
147158

148-
@Deprecated
149159
/**
150160
* Send server requests.
151161
*
152162
* @throws RemoteServerException the remote server exception
153163
* @throws LoginFailedException the login failed exception
154164
*/
165+
@Deprecated
155166
public void sendServerRequests() throws RemoteServerException, LoginFailedException {
156167
setLatitude(api.getLatitude());
157168
setLongitude(api.getLongitude());

0 commit comments

Comments
 (0)