Search in sources :

Example 6 with Summoner

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;
    }
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) Optional(java.util.Optional)

Example 7 with Summoner

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;
    }
}
Also used : Summoner(no.stelar7.api.l4j8.pojo.summoner.Summoner) Optional(java.util.Optional)

Example 8 with Summoner

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();
}
Also used : DataCallBuilder(no.stelar7.api.r4j.basic.calling.DataCallBuilder) JsonWriter(com.google.gson.stream.JsonWriter)

Example 9 with Summoner

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;
    }
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner)

Example 10 with Summoner

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);
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) IntStream(java.util.stream.IntStream) FileSystemCacheProvider(no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider) java.awt.image(java.awt.image) java.util(java.util) URL(java.net.URL) R4J(no.stelar7.api.r4j.impl.R4J) MatchListBuilder(no.stelar7.api.r4j.impl.lol.builders.matchv5.match.MatchListBuilder) DataCall(no.stelar7.api.r4j.basic.calling.DataCall) SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) no.stelar7.api.r4j.pojo.lol.match.v5(no.stelar7.api.r4j.pojo.lol.match.v5) ImageIO(javax.imageio.ImageIO) Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) Predicate(java.util.function.Predicate) AffineTransform(java.awt.geom.AffineTransform) Rectangle(no.stelar7.api.r4j.basic.utils.Rectangle) StaticChampion(no.stelar7.api.r4j.pojo.lol.staticdata.champion.StaticChampion) java.awt(java.awt) List(java.util.List) LeagueShard(no.stelar7.api.r4j.basic.constants.api.regions.LeagueShard) java.io(java.io) SecretFile(no.stelar7.api.r4j.tests.SecretFile) org.junit.jupiter.api(org.junit.jupiter.api) Item(no.stelar7.api.r4j.pojo.lol.staticdata.item.Item) no.stelar7.api.r4j.basic.constants.types.lol(no.stelar7.api.r4j.basic.constants.types.lol) no.stelar7.api.r4j.basic.utils(no.stelar7.api.r4j.basic.utils) SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) MatchListBuilder(no.stelar7.api.r4j.impl.lol.builders.matchv5.match.MatchListBuilder) FileSystemCacheProvider(no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)

Aggregations

Summoner (no.stelar7.api.r4j.pojo.lol.summoner.Summoner)33 SummonerBuilder (no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder)19 SpectatorBuilder (no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)15 Summoner (no.stelar7.api.l4j8.pojo.summoner.Summoner)13 SummonerBuilder (no.stelar7.api.l4j8.impl.builders.summoner.SummonerBuilder)9 R4J (no.stelar7.api.r4j.impl.R4J)7 FileSystemCacheProvider (no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)5 Optional (java.util.Optional)4 ChampionMasteryBuilder (no.stelar7.api.r4j.impl.lol.builders.championmastery.ChampionMasteryBuilder)4 ChampionMastery (no.stelar7.api.r4j.pojo.lol.championmastery.ChampionMastery)4 java.util (java.util)3 FileSystemCacheProvider (no.stelar7.api.l4j8.basic.cache.impl.FileSystemCacheProvider)3 L4J8 (no.stelar7.api.l4j8.impl.L4J8)3 MatchListBuilder (no.stelar7.api.l4j8.impl.builders.match.MatchListBuilder)3 JsonWriter (com.google.gson.stream.JsonWriter)2 java.awt (java.awt)2 AffineTransform (java.awt.geom.AffineTransform)2 java.awt.image (java.awt.image)2 java.io (java.io)2 URL (java.net.URL)2