8000 Added README · Petersil1998/Thresh-Java@1371cb0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 1371cb0

Browse files
committed
Added README
1 parent ffea98d commit 1371cb0

File tree

1 file changed

+179
-0
lines changed

1 file changed

+179
-0
lines changed

README.md

Lines changed: 179 additions & 0 deletions
73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
# Thresh
2+
3+
Thresh 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,
5+
etc. much easier. For Teamfight Tactics take a look at [Spatula](https://github.com/Petersil1998/Spatula)
6+
7+
## Usage
8+
9+
In Order for Thresh to work properly there are a few things you need to set up/call
10+
at the beginning of your application.
11+
12+
```JAVA
13+
public class Example {
14+
public static void main(String[] args) {
15+
// First we need to provide our Riot API Key. Ideally the API Key is encrypted
16+
Settings.setAPIKey(() -> EncryptionUtil.encrypt(System.getenv("API_KEY")));
17+
// If the provided API Key is encrypted, we need to provide a function to decrypt the API Key
18+
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);
22+
// We also need to provide a language. The language is used to static Data like Champions, Item, etc.
23+
Settings.setLanguage(Language.EN_US);
24+
// We also need to add the Loader for the static LoL Data
25+
Loader.addLoader(new LoLLoader());
26+
// Lastly we need to initialize the static Data
27+
Loader.init();
28+
}
29+
}
30+
```
31+
32+
Now Thresh is ready and set up!
33+
34+
## Examples
35+
36+
- **Summoner and Account Data**
37+
38+
```JAVA
39+
public class Example {
40+
public static void main(String[] args) {
41+
// Setup code...
42+
43+
Summoner faker = Summoner.getSummonerByName("Faker");
44+
int summonerLevel = faker.getSummonerLevel();
45+
// Get the URL for the profile Icon
46+
String profileIconURL = Util.getProfileIconURL(faker.getProfileIcon());
47+
// Get Account
48+
Account account = faker.getAccount();
49+
// Get the Tag (e.g. Faker#KR1)
50+
String tag = account.toString();
51+
}
52+
}
53+
```
54+
55+
- **Champion Mastery**
56+
57+
```JAVA
58+
public class Example {
59+
public static void main(String[] args) {
60+
// Setup code...
61+
62+
Summoner faker = Summoner.getSummonerByName("Faker");
63+
ChampionMasteries masteries = ChampionMasteries.getChampionMasteriesOfSummoner(faker.getId());
64+
// Get Mastery Score
65+
int masteryScore = masteries.getTotalMasteryPoints();
66+
// Get Mastery Points on all Champions Combined
67+
int totalMasteryPoints = masteries.getTotalMasteryPointsCombined();
68+
// Get a List of all Champion Masteries
69+
List<ChampionMasteries.Mastery> championMasteries = masteries.getChampionMasteries();
70+
for(ChampionMasteries.Mastery mastery: championMasteries) {
71+
// Get the Champion
72+
Champion champion = mastery.getChampion();
+
// Get the Mastery Level on that Champion
74+
int masteryLevel = mastery.getChampionLevel();
75+
// Get the Mastery Points on that Champion
76+
int masteryPoints = mastery.getChampionPoints();
77+
}
78+
}
79+
}
80+
```
81+
82+
- **Rank and Leagues**
83+
84+
```JAVA
85+
public class Example {
86+
public static void main(String[] args) {
87+
// Setup code...
88+
89+
Summoner faker = Summoner.getSummonerByName("Faker");
90+
// Get Solo/Duo and Flex Rank
91+
LoLRanked ranked = LoLRanked.getLoLRanksOfSummoner(faker.getId());
92+
RankEntry soloDuo = ranked.getRankSoloDuo();
93+
int lp = soloDuo.getLeaguePoints();
94+
RankEntry flex = ranked.getRankFlex5v5();
95+
96+
// Get Challenger Solo Queue Players
97+
League challengers = LoLRanked.getChallengerLeague(RankedQueue.SOLO_DUO);
98+
for(LeagueEntry leagueEntry: challengers.getEntries()) {
99+
// Get all players and their LP
100+
Summoner player = leagueEntry.getSummoner();
101+
int playerLp = leagueEntry.getLeaguePoints();
102+
}
103+
104+
// 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);
107+
}
108+
}
109+
```
110+
111+
- **Active Games**
112+
113+
```JAVA
114+
public class Example {
115+
public static void main(String[] args) {
116+
// Setup code...
117+
118+
Summoner faker = Summoner.getSummonerByName("Faker");
119+
// Get Active Game of a given Summoner
120+
ActiveGame game = ActiveGame.ofSummoner(faker.getId());
121+
Map map = game.getMap();
122+
String gameMode = game.getGameMode();
123+
int duration = game.getDuration();
124+
// Get all Players of the blue Side Team
125+
List<Participants> blueTeam = game.getBlueSideTeam();
126+
// Get a String, that can be entered in the Windows Commandline to spectate the Game
127+
String cmd = game.getSpectatorCommandWindows("C:\\");
128+
}
129+
}
130+
```
131+
132+
- **MatchHistory**
133+
134+
```JAVA
135+
public class Example {
136+
public static void main(String[] args) {
137+
// Setup code...
138+
139+
Summoner faker = Summoner.getSummonerByName("Faker");
140+
// Get the Player's Match History. The Seconds Parameter is a Filter.
141+
List<MatchDetails> matchHistory = MatchDetails.getMatchHistory(me, Map.of());
142+
MatchDetails latestGame = matchHistory.get(0);
143+
int duration = latestGame.getGameDuration();
144+
// Get Team-based Info like bans, barons killed, turrets killed, etc.
145+
List<Team> teams = latestGame.getTeams();
146+
// Get all the Players. Match Participants have A LOT of data like Items bought, Champion played,
147+
// Summoner Spells used, Damage Dealt, Pings used, etc.
148+
List<MatchParticipant> participants = latestGame.getParticipants();
149+
}
150+
}
151+
```
152+
The Match History Filter can have those values:
153+
154+
| Key | Description | Type |
155+
|-----------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|
156+
| startTime | Unix Timestamp in seconds. Only start Times after June 16th 2021 will have an effect. [More](https://developer.riotgames.com/apis#match-v5/GET_getMatchIdsByPUUID) | long |
157+
| endTime | Unix Timestamp in seconds. | long |
158+
| queue | Queue ID. Works mutually inclusive with **type**. [QueueTypes](https://github.com/Petersil1998/Thresh-Java/blob/master/src/main/java/net/petersil98/thresh/collection/QueueTypes.java) contains all valid queues | int |
159+
| type | Type of a Match. Works mutually inclusive with **queue** | String |
160+
| start | The offset of the first Match entry | int |
161+
| count | The Amount of Matches entries to return. Has to be between 0 and 100 | int |
162+
**Note**: *All values need to be passed as **Strings** in the filter*
163+
164+
165+
- **Collections**
166+
167+
The package [collection](https://github.com/Petersil1998/Thresh-Java/blob/master/src/main/java/net/petersil98/thresh/collection/) contains Classes, which like Collections of static Data including:
168+
169+
- Challenges
170+
- Champions
171+
- Items
172+
- Maps
173+
- QueueTypes
174+
- Runes
175+
- RuneStats (The 3 stats you can choose in a Rune Page like adaptive Force, Armor, MR, etc.)
176+
- RuneStyles (Precision, Domination, Sorcery, Resolve, Inspiration)
177+
- Summoner Spells
178+
179+
#### Feel free to give Feedback and add suggestions on how this library can be improved. <br>Thank you for using Thresh, you're awesome!

0 commit comments

Comments
 (0)
0