Search in sources :

Example 41 with Summoner

use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner in project L4J8 by stelar7.

the class RatelimitTest method testRateLimitThreaded.

@Test
@Disabled
public void testRateLimitThreaded() {
    try {
        String name = new SpectatorBuilder().withPlatform(LeagueShard.EUW1).getFeaturedGames().get(0).getParticipants().get(0).getSummonerName();
        Summoner s = new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(name).get();
        ExecutorService pool = Executors.newFixedThreadPool(8);
        for (int i2 = 0; i2 < 130; i2++) {
            pool.execute(() -> new SummonerBuilder().withPlatform(LeagueShard.EUW1).withSummonerId(s.getSummonerId()).get());
        }
        pool.shutdown();
        pool.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) SpectatorBuilder(no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)

Example 42 with Summoner

use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner in project L4J8 by stelar7.

the class RatelimitTest method testRateLimitWithSleep.

@Test
@Disabled
public void testRateLimitWithSleep() throws InterruptedException {
    String id = new SpectatorBuilder().withPlatform(LeagueShard.EUW1).getFeaturedGames().get(0).getParticipants().get(0).getSummonerName();
    Summoner s = new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withSummonerId(id).get();
    TimeUnit.SECONDS.sleep(10);
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withSummonerId(id).get();
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) SpectatorBuilder(no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)

Example 43 with Summoner

use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner in project L4J8 by stelar7.

the class MatchListV5Test method testMatchInvalidSpellSlots.

@Test
@Disabled
public void testMatchInvalidSpellSlots() throws IOException {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    MatchListBuilder builder = new MatchListBuilder();
    Summoner sum = Summoner.byName(LeagueShard.EUW1, "stelar7");
    LazyList<String> all = sum.getLeagueGames().getLazy();
    MatchBuilder mb = new MatchBuilder(sum.getPlatform());
    TimelineBuilder tb = new TimelineBuilder(sum.getPlatform());
    StringWriter sw = new StringWriter();
    JsonWriter sb = new JsonWriter(sw);
    sb.beginObject();
    int i = 0;
    for (String matchid : all) {
        if (i++ > 10)
            break;
        tb = tb.withId(matchid);
        mb = mb.withId(matchid);
        LOLMatch match = mb.getMatch();
        LOLTimeline lolTimeline = tb.getTimeline();
        List<TimelineDamageData> wierdEntries = new ArrayList<>();
        lolTimeline.getFrames().forEach(frame -> {
            frame.getEvents().forEach(event -> {
                if (event.getType() == EventType.CHAMPION_KILL) {
                    event.getVictimDamageReceived().forEach(d -> {
                        if (d.getSpellSlot() == SpellSlotType.INVALID || d.getSpellSlot() == SpellSlotType.UNDOCUMENTED || d.getSpellSlot() == SpellSlotType.UNUSED || d.getSpellSlot() == SpellSlotType.OUT_OF_BOUNDS) {
                            wierdEntries.add(d);
                        }
                    });
                    event.getVictimDamageDealt().forEach(d -> {
                        if (d.getSpellSlot() == SpellSlotType.INVALID || d.getSpellSlot() == SpellSlotType.UNDOCUMENTED || d.getSpellSlot() == SpellSlotType.UNUSED || d.getSpellSlot() == SpellSlotType.OUT_OF_BOUNDS) {
                            wierdEntries.add(d);
                        }
                    });
                }
            });
        });
        if (wierdEntries.size() > 0) {
            sb.name(tb.getID());
            sb.beginArray();
            for (TimelineDamageData wierdEntry : wierdEntries) {
                sb.jsonValue(Utils.getGson().toJson(wierdEntry));
            }
            sb.endArray();
        }
    }
    sb.endObject();
    sb.flush();
    String output = Utils.getGson().toJson(new JsonParser().parse(sw.toString()));
    Files.write(Paths.get("C:\\Users\\stelar7\\Desktop\\errors.json"), output.getBytes(StandardCharsets.UTF_8));
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) FileSystemCacheProvider(no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider) JsonWriter(com.google.gson.stream.JsonWriter) JsonParser(com.google.gson.JsonParser)

Example 44 with Summoner

use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner in project L4J8 by stelar7.

the class MatchListV5Test method testMatchParticipantIds.

@Test
@Disabled
public void testMatchParticipantIds() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    MatchListBuilder builder = new MatchListBuilder();
    Summoner sum = Summoner.byName(LeagueShard.EUW1, "fckmuffin");
    LazyList<String> all = sum.getLeagueGames().getLazy();
    MatchBuilder mb = new MatchBuilder(sum.getPlatform());
    TimelineBuilder tb = new TimelineBuilder(sum.getPlatform());
    for (String matchid : all) {
        tb = tb.withId(matchid);
        mb = mb.withId(matchid);
        LOLMatch match = mb.getMatch();
        LOLTimeline lolTimeline = tb.getTimeline();
        List<TimelineDamageData> wierdEntries = new ArrayList<>();
        lolTimeline.getFrames().forEach(frame -> {
            frame.getParticipantFrames().forEach((k, v) -> {
                if (!k.equals(String.valueOf(v.getParticipantId()))) {
                    System.out.println(matchid + " has mismatched participantid and key");
                }
            });
        });
    }
}
Also used : Summoner(no.stelar7.api.r4j.pojo.lol.summoner.Summoner) FileSystemCacheProvider(no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)

Example 45 with Summoner

use of no.stelar7.api.r4j.pojo.lol.summoner.Summoner in project L4J8 by stelar7.

the class CacheTest method testCacheStuff.

@Test
@Disabled
public void testCacheStuff() throws InterruptedException {
    Logger root = (Logger) LoggerFactory.getLogger(Logger.ROOT_LOGGER_NAME);
    root.setLevel(Level.INFO);
    System.out.println("Fetching summoner for the first time");
    DataCall.setCacheProvider(fileCache.get());
    String id = new SpectatorBuilder().withPlatform(LeagueShard.EUW1).getFeaturedGames().get(0).getParticipants().get(0).getSummonerName();
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    Thread.sleep(6000);
    System.out.println("Fetching summoner after cache timeout");
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    Map<String, Object> data = new TreeMap<>();
    data.put("platform", LeagueShard.EUW1);
    data.put("name", id);
    DataCall.getCacheProvider().clear(URLEndpoint.V4_SUMMONER_BY_NAME, data);
    System.out.println("Fetching summoner after deleting entry");
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    CacheLifetimeHint defaults = CacheLifetimeHint.DEFAULTS;
    defaults.add(URLEndpoint.V4_SUMMONER_BY_NAME, TimeUnit.SECONDS.toMillis(1));
    DataCall.getCacheProvider().setTimeToLive(defaults);
    Thread.sleep(1000);
    System.out.println("Fetching summoner after setting lifetime to a lower limit");
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
    new SummonerBuilder().withPlatform(LeagueShard.EUW1).withName(id).get();
}
Also used : SummonerBuilder(no.stelar7.api.r4j.impl.lol.builders.summoner.SummonerBuilder) CacheLifetimeHint(no.stelar7.api.r4j.basic.cache.CacheLifetimeHint) SpectatorBuilder(no.stelar7.api.r4j.impl.lol.builders.spectator.SpectatorBuilder)

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