Skip to content

Commit 2f59c37

Browse files
authored
Merge pull request #58 from stachu540/v3
merge to dev
2 parents 55d64ee + 2b318e0 commit 2f59c37

File tree

196 files changed

+4920
-3027
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+4920
-3027
lines changed

.codacy.yml

Lines changed: 0 additions & 6 deletions
This file was deleted.

.github/ISSUES_TEMPLATE.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 0 additions & 24 deletions
This file was deleted.

.gitignore

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
1+
.gradle/
2+
build/
3+
logs/
4+
15
.idea
26
*.iml
37
out/
4-
.gradle
5-
build/
6-
logs/
8+
9+
lombok.config
10+
11+
*.txt
12+
13+
all/src/
14+
BOM/src/

.travis.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: java
22
jdk:
33
- oraclejdk8
4+
- oraclejdk11
45

56
before_cache:
67
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
@@ -15,8 +16,23 @@ before_install:
1516
script:
1617
- ./gradlew test
1718

18-
deploy:
19-
- provider: script
20-
script: ./gradlew bintrayUpload
21-
on:
22-
tags: true
19+
20+
jobs:
21+
include:
22+
- stage: deploy
23+
jdk: openjdk11
24+
install: skip
25+
script: chmod +x ./javadoc.sh && ./javadoc.sh
26+
if: tag IS present
27+
deploy:
28+
provider: pages
29+
local-dir: ./javadoc
30+
api_key: $GITHUB_OAUTH_TOKEN
31+
skip_cleanup: true
32+
committer-from-gh: true
33+
verbose: true
34+
- stage: deploy
35+
jdk: openjdk8
36+
install: skip
37+
script: ./gradlew bintrayUpload -x test
38+
if: tag IS present

README.md

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
1-
[![Build Status](https://travis-ci.org/stachu540/HiRezAPI.svg)](https://travis-ci.org/stachu540/HiRezAPI)
1+
[![Build Status](https://travis-ci.com/stachu540/HiRezAPI.svg)](https://travis-ci.com/stachu540/HiRezAPI)
22
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/ee16a92996a3425d87403780aa18f316)](https://www.codacy.com/app/stachu540/HiRezAPI?utm_source=github.com&utm_medium=referral&utm_content=stachu540/HiRezAPI&utm_campaign=Badge_Grade)
3-
[![Download](https://api.bintray.com/packages/stachu540/Java/HiRezAPI/images/download.svg) ](https://bintray.com/stachu540/Java/HiRezAPI/_latestVersion)
3+
[![Download](https://api.bintray.com/packages/stachu540/Java/HiRezAPI/images/download.svg)](https://bintray.com/stachu540/Java/HiRezAPI/_latestVersion)
4+
45
##### Javadocs
5-
| Package | Javadoc |
6-
|---|---|
7-
| Common | [![Javadocs](http://javadoc.io/badge/com.github.stachu540/HiRezApi-common.svg)](http://javadoc.io/doc/com.github.stachu540/HiRezApi-common) |
8-
| Smite | [![Javadocs](http://javadoc.io/badge/com.github.stachu540/HiRezApi-smite.svg)](http://javadoc.io/doc/com.github.stachu540/HiRezApi-smite) |
9-
| Paladins | [![Javadocs](http://javadoc.io/badge/com.github.stachu540/HiRezApi-paladins.svg)](http://javadoc.io/doc/com.github.stachu540/HiRezApi-paladins) |
10-
| Core | [![Javadocs](http://javadoc.io/badge/com.github.stachu540/HiRezApi-core.svg)](http://javadoc.io/doc/com.github.stachu540/HiRezApi-core) |
6+
Soon :tm:
117

128
# HiRezAPI
139
Java-Based API Wrapper for Hi-Rez Studios games. Currently supports:
@@ -16,7 +12,7 @@ Java-Based API Wrapper for Hi-Rez Studios games. Currently supports:
1612

1713
## Features
1814

19-
All features will be on [Project](https://github.com/stachu540/HiRezAPI/projects/4) tab
15+
All features will be on [Project](https://github.com/stachu540/HiRezAPI/projects/5) tab
2016

2117
## Getting Started
2218

@@ -31,37 +27,41 @@ Add to `pom.xml` build.
3127
<repositories>
3228
<repository>
3329
<id>jcenter</id>
34-
<url>https://jcenter.bintray.com</url>
30+
<url>https://jitpack.io</url>
3531
</repository>
3632
</repositories>
3733

3834
<dependencies>
3935
<dependency>
4036
<groupId>com.github.stachu540</groupId>
4137
<!--for all games-->
42-
<artifactId>HiRezAPI-core</artifactId>
38+
<artifactId>HiRezAPI-all</artifactId>
4339
<!--for paladins-->
4440
<!--<artifactId>HiRezAPI-paladins</artifactId>-->
4541
<!--for smite-->
4642
<!--<artifactId>HiRezAPI-smite</artifactId>-->
47-
<version>2.1.0</version>
43+
<!--for realm royale-->
44+
<!--<artifactId>HiRezAPI-realm</artifactId>-->
45+
<version>v3</version>
4846
</dependency>
4947
</dependencies>
5048
```
5149
#### Gradle
5250
Add to `build.gradle` build.
5351
```groovy
5452
repositories {
55-
jcenter()
53+
maven { url "https://jitpack.io" }
5654
}
5755
5856
dependencies {
59-
// for all games
60-
compile "com.github.stachu540:HiRezAPI-core:2.1.0"
61-
// for paladins
62-
// compile "com.github.stachu540:HiRezAPI-paladins:2.1.0"
63-
// for smite
64-
// compile "com.github.stachu540:HiRezAPI-smite:2.1.0"
57+
// for all games
58+
compile "com.github.stachu540:HiRezAPI-all:v3"
59+
// for paladins
60+
// compile "com.github.stachu540:HiRezAPI-paladins:v3"
61+
// for smite
62+
// compile "com.github.stachu540:HiRezAPI-smite:v3"
63+
// for realm royale
64+
// compile "com.github.stachu540:HiRezAPI-realm:v3"
6565
}
6666
```
6767

all/build.gradle

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
def projectList = [
2+
project(":api"),
3+
project(":smite"),
4+
project(":paladins"),
5+
project(":realm")
6+
]
7+
8+
dependencies {
9+
projectList.each {
10+
compile it
11+
}
12+
}
13+
14+
sourceJar.enabled = false
15+
16+
javadoc {
17+
failOnError = false
18+
title = "${rootProject.name} ${rootProject.version} API"
19+
options {
20+
windowTitle = "${rootProject.name} ${rootProject.version}"
21+
author = true
22+
encoding = "UTF-8"
23+
quiet()
24+
}
25+
26+
projectList.each {
27+
source += it.javadoc.source
28+
classpath += it.javadoc.classpath
29+
excludes += it.javadoc.excludes
30+
includes += it.javadoc.includes
31+
}
32+
}

api/build.gradle

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
plugins {
2+
id "io.freefair.lombok"
3+
id "com.gorylenko.gradle-git-properties"
4+
}
5+
6+
dependencies {
7+
compile enforcedPlatform("com.fasterxml.jackson:jackson-bom:2.9.8")
8+
compile "com.fasterxml.jackson.core:jackson-annotations:2.9.8"
9+
10+
compile "com.fasterxml.jackson.core:jackson-databind"
11+
compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310"
12+
compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8"
13+
14+
compile "io.reactivex.rxjava2:rxjava:2.2.8"
15+
compile "io.reactivex.rxjava2:rxandroid:2.1.1"
16+
17+
compile "com.squareup.okhttp3:okhttp:3.14.0"
18+
compile "com.squareup.okhttp3:logging-interceptor:3.14.0"
19+
20+
testCompile "com.google.guava:guava:27.1-android"
21+
testCompile "com.squareup.okhttp3:mockwebserver:3.14.0"
22+
}
23+
24+
gitProperties {
25+
failOnNoGitDirectory = false
26+
keys = [
27+
"git.branch",
28+
"git.commit.id",
29+
"git.commit.id.abbrev",
30+
"git.commit.id.describe"
31+
]
32+
dateFormatTimeZone = "GMT"
33+
customProperty "application.name", rootProject.name
34+
customProperty "application.version", rootProject.version
35+
customProperty "application.url", "https://github.com/stachu540/hirezapi"
36+
customProperty "application.description", rootProject.description
37+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package hirez.api;
2+
3+
import hirez.api.object.Game;
4+
import hirez.api.object.Platform;
5+
6+
public interface BaseEndpoint {
7+
Game getGame();
8+
Platform getPlatform();
9+
String getBaseUrl();
10+
}
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package hirez.api;
2+
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Getter;
6+
7+
import java.security.MessageDigest;
8+
import java.security.NoSuchAlgorithmException;
9+
import java.text.SimpleDateFormat;
10+
import java.time.ZoneOffset;
11+
import java.util.Date;
12+
import java.util.TimeZone;
13+
14+
@Getter
15+
@AllArgsConstructor
16+
public class Configuration {
17+
private final String devId;
18+
private final String authKey;
19+
private final BaseEndpoint baseEndpoint;
20+
private final SessionStorage sessionStorage;
21+
private final String userAgent;
22+
private final Language language;
23+
24+
public Configuration(ConfigurationBuilder cb) {
25+
this(cb.getDevId(), cb.getAuthKey(), cb.getBaseEndpoint(), cb.getSessionStorage(), cb.getUserAgent(), cb.getLanguage());
26+
}
27+
28+
public String createUrl(String method, String... args) {
29+
StringBuilder sb = new StringBuilder(baseEndpoint.getBaseUrl())
30+
.append("/").append(method).append("json");
31+
32+
String timestamp = doTimestamp();
33+
34+
if (!method.equals("ping")) {
35+
sb.append("/").append(devId);
36+
sb.append("/").append(doSignature(method, timestamp));
37+
if (!method.equals("createsession") && sessionStorage.isPresent()) {
38+
sb.append("/").append(sessionStorage.get());
39+
} else {
40+
throw new HiRezException("Require generate session for: " + method);
41+
}
42+
sb.append("/").append(timestamp);
43+
if (args.length > 0) {
44+
sb.append("/").append(String.join("/", args));
45+
}
46+
}
47+
return sb.toString();
48+
}
49+
50+
51+
private String doTimestamp() {
52+
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
53+
sdf.setTimeZone(TimeZone.getTimeZone(ZoneOffset.UTC));
54+
return sdf.format(new Date());
55+
}
56+
57+
private String doSignature(String method, String timestamp) {
58+
String templateSignature = new StringBuilder(devId)
59+
.append(method)
60+
.append(authKey)
61+
.append(timestamp)
62+
.toString();
63+
StringBuilder signatureBuilder = new StringBuilder();
64+
try {
65+
MessageDigest md = MessageDigest.getInstance("MD5");
66+
md.update(templateSignature.getBytes());
67+
byte[] bytes = md.digest();
68+
69+
for (byte bit : bytes) {
70+
String hex = Integer.toHexString(0xff & bit);
71+
if (hex.length() == 1) {
72+
signatureBuilder.append("0");
73+
}
74+
signatureBuilder.append(hex);
75+
}
76+
} catch (NoSuchAlgorithmException ignore) {
77+
}
78+
79+
return signatureBuilder.toString();
80+
}
81+
82+
public ConfigurationBuilder newBuilder() {
83+
return new ConfigurationBuilder(this);
84+
}
85+
}

0 commit comments

Comments
 (0)