Thresh is an Object-Oriented Java Library, which takes over the Communication with the League of Legends API. It supports In-Memory caching and uses a (blocking) Rate Limiter. It makes retrieving Summoner Data, Match History, etc. much easier.
Other Projects:
- Spatula for Teamfight Tactics
- Scuttlegeist for Legends of Runeterra
- Fade for Valorant
Thresh can be included like this using Gradle:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
...
implementation 'com.github.Petersil1998:Core:v1.4'
implementation 'com.github.Petersil1998:STCommons:v1.4'
implementation 'com.github.Petersil1998:Thresh-Java:v1.4'
}or using Maven:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.Petersil1998</groupId>
<artifactId>Core</artifactId>
<version>v1.4</version>
</dependency>
<dependency>
<groupId>com.github.Petersil1998</groupId>
<artifactId>STCommons</artifactId>
<version>v1.4</version>
</dependency>
<dependency>
<groupId>com.github.Petersil1998</groupId>
<artifactId>Thresh-Java</artifactId>
<version>v1.4</version>
</dependency>In Order for Thresh to work properly there are a few things you need to set up at the beginning of your application.
publicclassExample {
publicstaticvoidmain(String[] args) {
// First we need to provide our Riot API Key. Ideally the API Key is encryptedSettings.setAPIKey(() -> EncryptionUtil.encrypt(System.getenv("API_KEY")));
// If the provided API Key is encrypted, we need to provide a function to decrypt the API KeySettings.setDecryptor(EncryptionUtil::decrypt);
// We also need to provide a language. The language is used to static Data like Champions, Item, etc.Settings.setLanguage(Language.EN_US);
// If we want to use caching we can enable it in the Settings. Caching is disabled by defaultSettings.useCache(true);
// We also need to add the Loader for the static LoL DataLoader.addLoader(newLoLLoader());
// Lastly we need to initialize the static DataLoader.init();
}
}Now Thresh is ready and set up!
Summoner and Account Data
publicclassExample { publicstaticvoidmain(String[] args) { // Setup code...Summonerfaker = Summoner.getSummonerByName("Faker", LeaguePlatform.KR); intsummonerLevel = faker.getSummonerLevel(); // Get the URL for the profile IconStringprofileIconURL = Util.getProfileIconURL(faker.getProfileIcon()); // Get AccountAccountaccount = Account.getAccountByPuuid(faker.getPuuid(), LeagueRegion.ASIA); // Get the Tag (e.g. Faker#KR1)Stringtag = account.toString(); } }
Champion Mastery
publicclassExample { publicstaticvoidmain(String[] args) { // Setup code...Summonerfaker = Summoner.getSummonerByName("Faker", LeaguePlatform.KR); ChampionMasteriesmasteries = ChampionMasteries.getChampionMasteriesOfSummoner(faker.getId(), LeaguePlatform.KR); // Get Mastery ScoreintmasteryScore = masteries.getTotalMasteryPoints(); // Get Mastery Points on all Champions CombinedinttotalMasteryPoints = masteries.getTotalMasteryPointsCombined(); // Get a List of all Champion MasteriesList<ChampionMasteries.Mastery> championMasteries = masteries.getChampionMasteries(); for(ChampionMasteries.Masterymastery: championMasteries) { // Get the ChampionChampionchampion = mastery.getChampion(); // Get the Mastery Level on that ChampionintmasteryLevel = mastery.getChampionLevel(); // Get the Mastery Points on that ChampionintmasteryPoints = mastery.getChampionPoints(); } } }
Rank and Leagues
publicclassExample { publicstaticvoidmain(String[] args) { // Setup code...Summonerfaker = Summoner.getSummonerByName("Faker", LeaguePlatform.KR); // Get Solo/Duo and Flex RankPlayerRanksranked = LoLRanked.getLoLRanksOfSummoner(faker.getId(), LeaguePlatform.KR); RankEntrysoloDuo = ranked.getRankSoloDuo(); intlp = soloDuo.getLeaguePoints(); RankEntryflex = ranked.getRankFlex5v5(); // Get Challenger Solo Queue PlayersLeaguechallengers = LoLRanked.getChallengerLeague(RankedQueue.SOLO_DUO, LeaguePlatform.EUW); for(LeagueEntryleagueEntry: challengers.getEntries()) { // Get all players and their LPSummonerplayer = Summoner.getSummonerByID(leagueEntry.getSummonerId(), LeaguePlatform.EUW); intplayerLp = leagueEntry.getLeaguePoints(); } // Get a list of Gold 1 Flex PlayersList<RankEntry> firstPage = LoLRanked.getRankEntries(RankedDivision.I, RankedTier.GOLD, RankedQueue.FLEX, LeaguePlatform.NA); List<RankEntry> secondPage = LoLRanked.getRankEntries(RankedDivision.I, RankedTier.GOLD, RankedQueue.FLEX, LeaguePlatform.NA, 2); } }
Active Games
publicclassExample { publicstaticvoidmain(String[] args) { // Setup code...Summonerfaker = Summoner.getSummonerByName("Faker", LeaguePlatform.NA); // Get Active Game of a given SummonerActiveGamegame = ActiveGame.ofSummoner(faker.getId(), LeaguePlatform.NA); Mapmap = game.getMap(); StringgameMode = game.getGameMode(); intduration = game.getDuration(); // Get all Players of the blue Side TeamList<Participant> blueTeam = game.getBlueSideTeam(); // Get a String, that can be entered in the Windows Commandline to spectate the GameStringcmd = game.getSpectatorCommandWindows("C:\\"); } }
Match History
publicclassExample { publicstaticvoidmain(String[] args) { // Setup code...Summonerfaker = Summoner.getSummonerByName("Faker", LeaguePlatform.NA); // Get the Player's Match History. The Seconds Parameter is a Filter.List<MatchDetails> matchHistory = MatchDetails.getMatchHistory(faker.getId(), LeagueRegion.ASIA, Map.of()); MatchDetailslatestGame = matchHistory.get(0); intduration = latestGame.getGameDuration(); // Get Team-based Info like bans, barons killed, turrets killed, etc.List<Team> teams = latestGame.getTeams(); // Get all the Players. Match Participants have A LOT of data like Items bought, Champion played,// Summoner Spells used, Damage Dealt, Pings used, etc.List<MatchParticipant> participants = latestGame.getParticipants(); } }
The Match History Filter can have the following values:
Key Description Type startTime Unix Timestamp in seconds. Only start Times after June 16th 2021 will have an effect. More long endTime Unix Timestamp in seconds. long queue Queue ID. Works mutually inclusive with type. QueueTypes contains all valid queues int type Type of a Match. Works mutually inclusive with queue String start The offset of the first Match entry int count The Amount of Matches entries to return. Has to be between 0 and 100 int Note: All values need to be passed as Strings in the filter
Collections
The package collection contains a bunch of Collections for static Data including:
- Challenges
- Champions
- Items
- Maps
- QueueTypes
- Runes
- RuneStats (The 3 stats you can choose in a Rune Page like adaptive Force, Armor, MR, etc.)
- RuneStyles (Precision, Domination, Sorcery, Resolve, Inspiration)
- Summoner Spells