chat commands: add ba high gamble command

This commit is contained in:
Jacob McElroy
2019-06-27 08:50:32 -04:00
committed by Adam
parent 1e112f97d5
commit 8757d25bd3
6 changed files with 166 additions and 0 deletions

View File

@@ -216,4 +216,46 @@ public class ChatClient
return Integer.parseInt(response.body().string());
}
}
public boolean submitGc(String username, int gc) throws IOException
{
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("chat")
.addPathSegment("gc")
.addQueryParameter("name", username)
.addQueryParameter("gc", Integer.toString(gc))
.build();
Request request = new Request.Builder()
.post(RequestBody.create(null, new byte[0]))
.url(url)
.build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
{
return response.isSuccessful();
}
}
public int getGc(String username) throws IOException
{
HttpUrl url = RuneLiteAPI.getApiBase().newBuilder()
.addPathSegment("chat")
.addPathSegment("gc")
.addQueryParameter("name", username)
.build();
Request request = new Request.Builder()
.url(url)
.build();
try (Response response = RuneLiteAPI.CLIENT.newCall(request).execute())
{
if (!response.isSuccessful())
{
throw new IOException("Unable to look up gamble count!");
}
return Integer.parseInt(response.body().string());
}
}
}