use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner in project L4J8 by stelar7.
the class SummonerAPI method getSummonerByAccount.
/**
* The response object contains the summoner objects mapped by their username.
*
* @param server the region to execute against
* @param accountId accountId associated with summoner to retrieve.
* @return Optional Summoner
*/
public Summoner getSummonerByAccount(final Platform server, long accountId) {
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.ACCOUNT_ID_PLACEHOLDER, String.valueOf(accountId)).withEndpoint(URLEndpoint.V3_SUMMONER_BY_ACCOUNT).withPlatform(server);
Optional chl = DataCall.getCacheProvider().get(URLEndpoint.V3_SUMMONER_BY_ACCOUNT, server, accountId);
if (chl.isPresent()) {
return (Summoner) chl.get();
}
try {
Summoner summoner = (Summoner) builder.build();
DataCall.getCacheProvider().store(URLEndpoint.V3_SUMMONER_BY_ACCOUNT, summoner, server, accountId);
return summoner;
} catch (ClassCastException e) {
return null;
}
}
use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner in project L4J8 by stelar7.
the class SummonerAPI method getSummonerById.
/**
* The response object contains the summoner objects mapped by their user id.
*
* @param server the region to execute against
* @param summonerId summonerId associated with summoners to retrieve.
* @return Optional Summoner
*/
public Summoner getSummonerById(final Platform server, long summonerId) {
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.SUMMONER_ID_PLACEHOLDER, String.valueOf(summonerId)).withEndpoint(URLEndpoint.V3_SUMMONER_BY_ID).withPlatform(server);
Optional chl = DataCall.getCacheProvider().get(URLEndpoint.V3_SUMMONER_BY_ID, server, "", summonerId);
if (chl.isPresent()) {
return (Summoner) chl.get();
}
try {
Summoner summoner = (Summoner) builder.build();
DataCall.getCacheProvider().store(URLEndpoint.V3_SUMMONER_BY_ID, summoner, server, "", summonerId);
return summoner;
} catch (ClassCastException e) {
return null;
}
}
use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner in project L4J8 by stelar7.
the class LCUApi method inviteSummoner.
/**
* Invites the summoner to your game
* @param name the name
*/
public static void inviteSummoner(String name) {
StringWriter sw = new StringWriter();
try {
JsonWriter jw = new JsonWriter(sw);
JsonObject obj = getSummoner(name);
jw.beginArray().beginObject().name("toSummonerId").value(obj.get("summonerId").getAsString()).name("toSummonerName").value(obj.get("internalName").getAsString()).endObject().endArray();
} catch (IOException e) {
e.printStackTrace();
}
String postData = sw.toString();
Pair<String, String> header = LCUConnection.getAuthorizationHeader();
JsonArray obj = (JsonArray) new DataCallBuilder().withLimiters(false).withProxy(LCUConnection.getConnectionString() + Constants.GSVR).withEndpoint(URLEndpoint.LCU_LOBBY_INVITE).withRequestMethod("POST").withHeader(header.getKey(), header.getValue()).withPostData(postData).build();
}
use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner in project L4J8 by stelar7.
the class TFTSummonerAPI method getSummonerById.
/**
* The response object contains the summoner objects mapped by their user id.
*
* @param server the region to execute against
* @param summonerId summonerId associated with summoners to retrieve.
* @return Optional Summoner
*/
public Summoner getSummonerById(final LeagueShard server, String summonerId) {
DataCallBuilder builder = new DataCallBuilder().withURLParameter(Constants.SUMMONER_ID_PLACEHOLDER, summonerId).withHeader(Constants.X_RIOT_TOKEN_HEADER_KEY, DataCall.getCredentials().getTFTAPIKey()).withEndpoint(URLEndpoint.V1_TFT_SUMMONER_BY_ID).withPlatform(server);
Map<String, Object> data = new TreeMap<>();
data.put("platform", server);
data.put("id", summonerId);
Optional<?> chl = DataCall.getCacheProvider().get(URLEndpoint.V1_TFT_SUMMONER_BY_ID, data);
if (chl.isPresent()) {
return (Summoner) chl.get();
}
try {
Summoner summoner = (Summoner) builder.build();
data.put("value", summoner);
DataCall.getCacheProvider().store(URLEndpoint.V1_TFT_SUMMONER_BY_ID, data);
return summoner;
} catch (ClassCastException e) {
return null;
}
}
use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner in project L4J8 by stelar7.
the class FrameToImageTest method testStuff.
@Test
@Disabled
public void testStuff() {
DataCall.setCacheProvider(new FileSystemCacheProvider());
Summoner sum = new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName("stelar7").get();
LazyList<String> refs = new MatchListBuilder().withPlatform(sum.getPlatform()).withPuuid(sum.getAccountId()).getLazy();
LOLMatch full = LOLMatch.get(sum.getPlatform(), refs.get(0));
TowerLocationType.getTowersMap(MapType.SUMMONERS_RIFT).forEach((k, v) -> v.forEach((k2, v2) -> v2.forEach((t, p) -> turretTeam.put(p, t))));
turretTeam.forEach((k, v) -> turrets.add(k));
InhibitorLocationType.getInhibMap(MapType.SUMMONERS_RIFT).forEach((k, v) -> v.forEach((t, p) -> inhibTeam.put(p, t)));
inhibTeam.forEach((k, v) -> inhib.add(k));
generateMinimap(full);
}
Aggregations