Search in sources :

Example 1 with VALMatchAPI

use of no.stelar7.api.r4j.impl.val.VALMatchAPI in project L4J8 by stelar7.

the class TestVALMatch method getList.

@Test
public void getList() {
    DataCall.setCacheProvider(new FileSystemCacheProvider());
    DataCall.getCacheProvider().clear(URLEndpoint.V1_VAL_MATCHLIST_BY_PUUID, new HashMap<>());
    R4J api = new R4J(SecretFile.CREDS);
    VALMatchAPI matchAPI = api.getVALAPI().getMatchAPI();
    RiotAccount account = api.getAccountAPI().getAccountByTag(RegionShard.EUROPE, "stelar7", "stl7");
    List<MatchReference> matchlist = matchAPI.getMatchList(ValorantShard.EU, account.getPUUID());
    System.out.println(matchlist);
}
Also used : RiotAccount(no.stelar7.api.r4j.pojo.shared.RiotAccount) VALMatchAPI(no.stelar7.api.r4j.impl.val.VALMatchAPI) R4J(no.stelar7.api.r4j.impl.R4J) FileSystemCacheProvider(no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)

Example 2 with VALMatchAPI

use of no.stelar7.api.r4j.impl.val.VALMatchAPI in project L4J8 by stelar7.

the class TestVALMatch method getRecent.

@Test
public void getRecent() {
    R4J api = new R4J(SecretFile.CREDS);
    VALMatchAPI matchAPI = api.getVALAPI().getMatchAPI();
    RecentMatchList recentMatches = matchAPI.getRecentMatches(ValorantShard.EU, GameQueueType.COMPETITIVE);
    System.out.println(recentMatches);
}
Also used : VALMatchAPI(no.stelar7.api.r4j.impl.val.VALMatchAPI) R4J(no.stelar7.api.r4j.impl.R4J)

Example 3 with VALMatchAPI

use of no.stelar7.api.r4j.impl.val.VALMatchAPI in project L4J8 by stelar7.

the class TestVALMatch method testGetSingleById.

@Test
public void testGetSingleById() {
    R4J api = new R4J(SecretFile.CREDS);
    VALMatchAPI matchAPI = api.getVALAPI().getMatchAPI();
    VALMatch match = matchAPI.getMatch(ValorantShard.AP, "c4eb3e3d-d175-4b73-b7d4-279374d1b19b");
    System.out.println();
}
Also used : VALMatchAPI(no.stelar7.api.r4j.impl.val.VALMatchAPI) R4J(no.stelar7.api.r4j.impl.R4J)

Example 4 with VALMatchAPI

use of no.stelar7.api.r4j.impl.val.VALMatchAPI in project L4J8 by stelar7.

the class TestVALMatch method generateRecentGamesData.

@Test
@Disabled
public void generateRecentGamesData() throws IOException {
    LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
    loggerContext.getLogger("no.stelar7.api.r4j.basic.calling.DataCallBuilder").setLevel(Level.INFO);
    loggerContext.getLogger("no.stelar7.api.r4j.basic.ratelimiting.BurstRateLimiter").setLevel(Level.INFO);
    while (true) {
        DataCall.getCacheProvider().clear(URLEndpoint.V1_VAL_MATCH_BY_ID, new HashMap<>());
        Map<String, JsonElement> matches = new HashMap<>();
        Map<String, JsonElement> players = new HashMap<>();
        R4J api = new R4J(SecretFile.CREDS);
        VALMatchAPI matchAPI = api.getVALAPI().getMatchAPI();
        RecentMatchList recentMatches = matchAPI.getRecentMatches(ValorantShard.EU, GameQueueType.COMPETITIVE);
        List<String> matchIds = recentMatches.getMatchIds().stream().limit(100).collect(Collectors.toList());
        int max = matchIds.size();
        int current = 0;
        for (String matchId : matchIds) {
            System.out.println("Working on match " + (++current) + "/" + max);
            VALMatch match = matchAPI.getMatch(ValorantShard.EU, matchId);
            JsonElement matchJson = Utils.getGson().toJsonTree(match);
            matches.put(matchId, matchJson);
            for (Player player : match.getPlayers()) {
                RiotAccount account = api.getAccountAPI().getAccountByPUUID(RegionShard.EUROPE, player.getPUUID());
                JsonElement accountJson = Utils.getGson().toJsonTree(account);
                players.put(account.getPUUID(), accountJson);
            }
        }
        JsonArray matchJson = new JsonArray();
        for (JsonElement value : matches.values()) {
            matchJson.add(value);
        }
        JsonArray playerJson = new JsonArray();
        for (JsonElement value : players.values()) {
            playerJson.add(value);
        }
        JsonObject obj = new JsonObject();
        obj.add("players", playerJson);
        obj.add("matches", matchJson);
        Path outputPath = Paths.get("C:\\cdragon\\valorant\\" + recentMatches.getGeneratedAt() + ".json");
        Files.createDirectories(outputPath.getParent());
        Files.write(outputPath, Utils.getGson().toJson(obj).getBytes(StandardCharsets.UTF_8));
    }
}
Also used : VALMatchAPI(no.stelar7.api.r4j.impl.val.VALMatchAPI) R4J(no.stelar7.api.r4j.impl.R4J) URLEndpoint(no.stelar7.api.r4j.basic.constants.api.URLEndpoint) RiotAccount(no.stelar7.api.r4j.pojo.shared.RiotAccount)

Example 5 with VALMatchAPI

use of no.stelar7.api.r4j.impl.val.VALMatchAPI in project L4J8 by stelar7.

the class TestVALMatch method getSingle.

@Test
public void getSingle() throws IOException {
    R4J api = new R4J(SecretFile.CREDS);
    VALMatchAPI matchAPI = api.getVALAPI().getMatchAPI();
    RiotAccount account = api.getAccountAPI().getAccountByTag(RegionShard.EUROPE, "Coup De Graçe", "EUNE");
    List<MatchReference> matchlist = matchAPI.getMatchList(ValorantShard.EU, account.getPUUID());
    VALMatch match = matchAPI.getMatch(ValorantShard.EU, matchlist.get(0).getMatchId());
    Files.write(Paths.get(System.getProperty("user.home") + "\\Desktop\\game.json"), Utils.getGson().toJson(match).getBytes(StandardCharsets.UTF_8));
    System.out.println(match);
}
Also used : RiotAccount(no.stelar7.api.r4j.pojo.shared.RiotAccount) VALMatchAPI(no.stelar7.api.r4j.impl.val.VALMatchAPI) R4J(no.stelar7.api.r4j.impl.R4J)

Aggregations

R4J (no.stelar7.api.r4j.impl.R4J)6 VALMatchAPI (no.stelar7.api.r4j.impl.val.VALMatchAPI)6 RiotAccount (no.stelar7.api.r4j.pojo.shared.RiotAccount)4 FileSystemCacheProvider (no.stelar7.api.r4j.basic.cache.impl.FileSystemCacheProvider)1 URLEndpoint (no.stelar7.api.r4j.basic.constants.api.URLEndpoint)1