use of no.stelar7.api.l4j8.basic.utils.Pair in project L4J8 by stelar7.
the class LCUApi method joinLobby.
/**
* Joins the lobby with the specified id
* <p>
* returns true if lobby exists, and we are able to join
* @param id the lobbyid
* @return true if able to join
*/
public static boolean joinLobby(String id) {
try {
Pair<String, String> header = LCUConnection.getAuthorizationHeader();
new DataCallBuilder().withLimiters(false).withProxy(LCUConnection.getConnectionString() + Constants.GSVR).withEndpoint(URLEndpoint.LCU_LOBBY_JOIN).withURLParameter(Constants.ID_PLACEHOLDER, id).withRequestMethod("POST").withHeader(header.getKey(), header.getValue()).build();
return true;
} catch (APIResponseException e) {
return false;
}
}
use of no.stelar7.api.l4j8.basic.utils.Pair in project L4J8 by stelar7.
the class LCUApi method downloadReplay.
/**
* Downloads replay
* @param gameid the id to download
*/
public static void downloadReplay(Long gameid) {
Pair<String, String> header = LCUConnection.getAuthorizationHeader();
StringWriter sw = new StringWriter();
try {
JsonWriter jw = new JsonWriter(sw);
jw.beginObject().name("componentType").value("string").endObject();
} catch (IOException e) {
e.printStackTrace();
}
String postData = sw.toString();
JsonObject obj = (JsonObject) new DataCallBuilder().withLimiters(false).withProxy(LCUConnection.getConnectionString() + Constants.GSVR).withEndpoint(URLEndpoint.LCU_REPLAY_DOWNLOAD).withRequestMethod("POST").withURLParameter(Constants.GAMEID_PLACEHOLDER, gameid.toString()).withPostData(postData).withHeader(header.getKey(), header.getValue()).build();
}
use of no.stelar7.api.l4j8.basic.utils.Pair in project L4J8 by stelar7.
the class LCUApi method login.
/**
* Attempts to login to the client
*
* @param username your username
* @param password your password
* @return the login object
*/
public static JsonObject login(String username, String password) {
Pair<String, String> header = LCUConnection.getAuthorizationHeader();
StringWriter sw = new StringWriter();
try {
JsonWriter jw = new JsonWriter(sw);
jw.beginObject().name("username").value(username).name("password").value(password).endObject();
} catch (IOException e) {
e.printStackTrace();
}
String postData = sw.toString();
JsonObject obj = (JsonObject) new DataCallBuilder().withLimiters(false).withProxy(LCUConnection.getConnectionString() + Constants.GSVR).withEndpoint(URLEndpoint.LCU_LOGIN).withRequestMethod("POST").withPostData(postData).withHeader(header.getKey(), header.getValue()).build();
return obj;
}
use of no.stelar7.api.l4j8.basic.utils.Pair in project L4J8 by stelar7.
the class LCUApi method spectateGame.
/**
* Start spectator on game
* @param gameid the id to spectate
*/
public static void spectateGame(Long gameid) {
Pair<String, String> header = LCUConnection.getAuthorizationHeader();
StringWriter sw = new StringWriter();
try {
JsonWriter jw = new JsonWriter(sw);
jw.beginObject().name("componentType").value("string").endObject();
} catch (IOException e) {
e.printStackTrace();
}
String postData = sw.toString();
JsonObject obj = (JsonObject) new DataCallBuilder().withLimiters(false).withProxy(LCUConnection.getConnectionString() + Constants.GSVR).withEndpoint(URLEndpoint.LCU_REPLAY_WATCH).withRequestMethod("POST").withURLParameter(Constants.GAMEID_PLACEHOLDER, gameid.toString()).withPostData(postData).withHeader(header.getKey(), header.getValue()).build();
}
use of no.stelar7.api.l4j8.basic.utils.Pair in project L4J8 by stelar7.
the class LiveClientDataAPI method getGameData.
public static ActiveGameData getGameData() {
try {
Object data = new DataCallBuilder().withLimiters(false).withProxy(Constants.CLIENT_PROXY).withEndpoint(URLEndpoint.LIVECLIENT_GAME_DATA).withRequestMethod("GET").build();
if (data instanceof Pair) {
return null;
}
JsonObject obj = ((JsonElement) data).getAsJsonObject();
ActiveGameData returnMe = new ActiveGameData(Utils.getGson().fromJson(obj.get("activePlayer"), ActiveGameClientPlayer.class), Utils.getGson().fromJson(obj.get("allPlayers"), new TypeToken<List<ActiveGamePlayer>>() {
}.getType()), parseEventObjectToList(obj.get("events")), Utils.getGson().fromJson(obj.get("gameData"), ActiveGameState.class));
return returnMe;
} catch (APIResponseException e) {
return null;
}
}
Aggregations