11# Thresh
22
33Thresh is an Object-Oriented Java Library, which takes over the Communication
4- with the League of Legends API. It makes retrieving Summoner Data, Match History,
4+ with the League of Legends API. It supports In-Memory caching and uses a (blocking) Rate Limiter. It makes retrieving Summoner Data, Match History,
55etc. much easier. For Teamfight Tactics take a look at [ Spatula] ( https://github.com/Petersil1998/Spatula )
66
77## Usage
88
9- In Order for Thresh to work properly there are a few things you need to set up/call
9+ In Order for Thresh to work properly there are a few things you need to set up
1010at the beginning of your application.
1111
1212``` JAVA
@@ -16,11 +16,10 @@ public class Example {
1616 Settings . setAPIKey(() - > EncryptionUtil . encrypt(System . getenv(" API_KEY" )));
1717 // If the provided API Key is encrypted, we need to provide a function to decrypt the API Key
1818 Settings . setDecryptor(EncryptionUtil :: decrypt);
19- // We also need to set a Server Configuration consisting of a platform (e.g. EUW) and a region (e.g. EUROPE).
20- // Some predefined Configurations can be found in the ServerConfig class
21- Settings . setServerConfig(ServerConfig . EUW_CONFIG );
2219 // We also need to provide a language. The language is used to static Data like Champions, Item, etc.
2320 Settings . setLanguage(Language . EN_US );
21+ // If we want to use caching we can enable it in the Settings. Caching is disabled by default
22+ Settings . useCache(true );
2423 // We also need to add the Loader for the static LoL Data
2524 Loader . addLoader(new LoLLoader ());
2625 // Lastly we need to initialize the static Data
@@ -40,12 +39,12 @@ Now Thresh is ready and set up!
4039 public static void main (String [] args ) {
4140 // Setup code...
4241
43- Summoner faker = Summoner . getSummonerByName(" Faker" );
42+ Summoner faker = Summoner . getSummonerByName(" Faker" , Platform . KR );
4443 int summonerLevel = faker. getSummonerLevel();
4544 // Get the URL for the profile Icon
4645 String profileIconURL = Util . getProfileIconURL(faker. getProfileIcon());
4746 // Get Account
48- Account account = faker. getAccount( );
47+ Account account = Account . getAccountByPuuid( faker. getPuuid(), Region . ASIA );
4948 // Get the Tag (e.g. Faker#KR1)
5049 String tag = account. toString();
5150 }
@@ -59,8 +58,8 @@ Now Thresh is ready and set up!
5958 public static void main (String [] args ) {
6059 // Setup code...
6160
62- Summoner faker = Summoner . getSummonerByName(" Faker" );
63- ChampionMasteries masteries = ChampionMasteries . getChampionMasteriesOfSummoner(faker. getId());
61+ Summoner faker = Summoner . getSummonerByName(" Faker" , Platform . KR );
62+ ChampionMasteries masteries = ChampionMasteries . getChampionMasteriesOfSummoner(faker. getId(), Platform . KR );
6463 // Get Mastery Score
6564 int masteryScore = masteries. getTotalMasteryPoints();
6665 // Get Mastery Points on all Champions Combined
@@ -86,24 +85,24 @@ Now Thresh is ready and set up!
8685 public static void main (String [] args ) {
8786 // Setup code...
8887
89- Summoner faker = Summoner . getSummonerByName(" Faker" );
88+ Summoner faker = Summoner . getSummonerByName(" Faker" , Platform . KR );
9089 // Get Solo/Duo and Flex Rank
91- LoLRanked ranked = LoLRanked . getLoLRanksOfSummoner(faker. getId());
90+ LoLRanked ranked = LoLRanked . getLoLRanksOfSummoner(faker. getId(), Platform . KR );
9291 RankEntry soloDuo = ranked. getRankSoloDuo();
9392 int lp = soloDuo. getLeaguePoints();
9493 RankEntry flex = ranked. getRankFlex5v5();
9594
9695 // Get Challenger Solo Queue Players
97- League challengers = LoLRanked . getChallengerLeague(RankedQueue . SOLO_DUO );
96+ League challengers = LoLRanked . getChallengerLeague(RankedQueue . SOLO_DUO, Platform . EUW );
9897 for (LeagueEntry leagueEntry: challengers. getEntries()) {
9998 // Get all players and their LP
100- Summoner player = leagueEntry. getSummoner();
99+ Summoner player = Summoner . getSummonerByID( leagueEntry. getSummonerId(), Platform . EUW )
101100 int playerLp = leagueEntry. getLeaguePoints();
102101 }
103102
104103 // Get a list of Gold 1 Flex Players
105- List<RankEntry > firstPage = LoLRanked . getRankEntries(RankedDivision . I , RankedTier . GOLD , RankedQueue . FLEX );
106- List<RankEntry > secondPage = LoLRanked . getRankEntries(RankedDivision . I , RankedTier . GOLD , RankedQueue . FLEX , 2 );
104+ List<RankEntry > firstPage = LoLRanked . getRankEntries(RankedDivision . I , RankedTier . GOLD , RankedQueue . FLEX, Platform . NA );
105+ List<RankEntry > secondPage = LoLRanked . getRankEntries(RankedDivision . I , RankedTier . GOLD , RankedQueue . FLEX , Platform . NA , 2 );
107106 }
108107 }
109108 ```
@@ -115,14 +114,14 @@ Now Thresh is ready and set up!
115114 public static void main (String [] args ) {
116115 // Setup code...
117116
118- Summoner faker = Summoner . getSummonerByName(" Faker" );
117+ Summoner faker = Summoner . getSummonerByName(" Faker" , Platform . NA );
119118 // Get Active Game of a given Summoner
120- ActiveGame game = ActiveGame . ofSummoner(faker. getId());
119+ ActiveGame game = ActiveGame . ofSummoner(faker. getId(), Platform . NA );
121120 Map map = game. getMap();
122121 String gameMode = game. getGameMode();
123122 int duration = game. getDuration();
124123 // Get all Players of the blue Side Team
125- List<Participants > blueTeam = game. getBlueSideTeam();
124+ List<Participant > blueTeam = game. getBlueSideTeam();
126125 // Get a String, that can be entered in the Windows Commandline to spectate the Game
127126 String cmd = game. getSpectatorCommandWindows(" C:\\ " );
128127 }
@@ -136,9 +135,9 @@ Now Thresh is ready and set up!
136135 public static void main (String [] args ) {
137136 // Setup code...
138137
139- Summoner faker = Summoner . getSummonerByName(" Faker" );
138+ Summoner faker = Summoner . getSummonerByName(" Faker" , Platform . NA );
140139 // Get the Player's Match History. The Seconds Parameter is a Filter.
141- List<MatchDetails > matchHistory = MatchDetails . getMatchHistory(me , Map . of());
140+ List<MatchDetails > matchHistory = MatchDetails . getMatchHistory(faker . getId(), Region . ASIA , Map . of());
142141 MatchDetails latestGame = matchHistory. get(0 );
143142 int duration = latestGame. getGameDuration();
144143 // Get Team-based Info like bans, barons killed, turrets killed, etc.
0 commit comments