Skip to content

Commit 2d7c029

Browse files
committed
Initial commit.
0 parents  commit 2d7c029

File tree

12 files changed

+1217
-0
lines changed

12 files changed

+1217
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target/

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2019 Manos Paterakis
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# Java-SteamGridDB
2+
A Java wrapper for SteamGridDB's API
3+
4+
### Installation
5+
6+
[![](https://jitpack.io/v/mpaterakis/java-steamgriddb.svg)](https://jitpack.io/#mpaterakis/java-steamgriddb)
7+
8+
## Getting Started
9+
#### Get your API key
10+
[You can generate an API key on the preferences page.](https://www.steamgriddb.com/profile/preferences)
11+
12+
#### Require the library into your project.
13+
```java
14+
import com.SteamGridDB.*;
15+
import com.SteamGridDB.Enums.*;
16+
import com.SteamGridDB.Connection.*;
17+
```
18+
19+
#### Initialize the SGDBConnectionManager using your API key and the API base uri
20+
```java
21+
SGDBConnectionManager.initialize("https://www.steamgriddb.com/api/v2", "myAuthKey");
22+
```
23+
24+
#### Search for a game:
25+
```java
26+
// Get an ArrayList of games that match the search term
27+
var games = Search.searchGamesByName("cyberpunk");
28+
29+
// Get a JSONObject containing the response from the API [Can be converted to string using .toString()]
30+
var gamesJson = Search.searchGamesByNameJSON("cyberpunk");
31+
```
32+
33+
#### Get a game object without searching:
34+
```java
35+
// Get a Game using a GameId
36+
var game = Game.getGameByGameId(1234);
37+
38+
// Get a Game using a SteamAppId
39+
var game = Game.getGameBySteamAppId(567890);
40+
41+
// Get a Game using its constructor
42+
var game = new Game(567890, SGDBIdTypes.SteamAppId);
43+
```
44+
45+
#### Do something with a game object:
46+
```java
47+
// Get a Game's Name
48+
var gameName = game.getName();
49+
50+
// Get a Game's styles
51+
var stylesArray = game.getStyles();
52+
```
53+
54+
#### Get some grids:
55+
```java
56+
// Get grids by game ID
57+
var grid = Grid.getGridsByGameId(1234);
58+
59+
// Get grids by Steam App Id
60+
var grids = Grid.getGridsBySteamAppId(1234);
61+
62+
// Alternatively, you can do it like this:
63+
var grids = Grid.getGridsById(1234, SGDBIdTypes.GameId);
64+
```
65+
66+
#### Filter the styles:
67+
```java
68+
// Create an SGDBStyles array
69+
SGDBStyles styles[] = {SGDBStyles.Alternate, SGDBStyles.NoLogo};
70+
71+
// Same as before, but using the styles filter
72+
var grid = Grid.getGridsByGameId(1234, styles);
73+
74+
var grids = Grid.getGridsBySteamAppId(1234, styles);
75+
76+
var grids = Grid.getGridsById(1234, SGDBIdTypes.GameId, styles);
77+
```
78+
79+
#### Do something with a grid object:
80+
```java
81+
// Get the first Grid's score
82+
var gridScore = grids.get(0).getScore();
83+
84+
// Get the same Grid's Author's username
85+
var authorName = grids.get(0).getAuthor().getName();
86+
```
87+
88+
## Other methods
89+
#### Vote on grids:
90+
```java
91+
// Upvote the first grid of the game with ID 1234
92+
var grid = Grid.getGridsByGameId(1234).get(0);
93+
grid.upvote();
94+
95+
// Downvote the same grid
96+
var grid = Grid.getGridsByGameId(1234).get(0);
97+
grid.upvote();
98+
99+
// Alternatively, use the Grid's ID (80 in this case) to vote:
100+
Grid.upvoteById(80);
101+
Grid.downvoteById(80);
102+
```
103+
104+
#### Upload a grid:
105+
```java
106+
// Upload a blurred grid to Half-Life 2 (2254)
107+
Grid.upload(2254, SGDBStyles.Blurred, "path/of/image.img");
108+
```
109+
110+
#### Delete grids:
111+
```java
112+
// Delete a grid by ID
113+
Grid.deleteByGridID(gameID);
114+
115+
// Delete multiple grids by ID
116+
var gameIDs = {123, 456};
117+
Grid.deleteByGridIDs(gameIDs);
118+
119+
// Delete a Grid object
120+
var grid = Grid.getGridsByGameId(1234).get(0);
121+
grid.delete();
122+
```

nbactions.xml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<actions>
3+
<action>
4+
<actionName>run</actionName>
5+
<packagings>
6+
<packaging>jar</packaging>
7+
</packagings>
8+
<goals>
9+
<goal>process-classes</goal>
10+
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
11+
</goals>
12+
<properties>
13+
<exec.args>-classpath %classpath ${packageClassName}</exec.args>
14+
<exec.executable>java</exec.executable>
15+
</properties>
16+
</action>
17+
<action>
18+
<actionName>debug</actionName>
19+
<packagings>
20+
<packaging>jar</packaging>
21+
</packagings>
22+
<goals>
23+
<goal>process-classes</goal>
24+
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
25+
</goals>
26+
<properties>
27+
<exec.args>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath ${packageClassName}</exec.args>
28+
<exec.executable>java</exec.executable>
29+
<jpda.listen>true</jpda.listen>
30+
</properties>
31+
</action>
32+
<action>
33+
<actionName>profile</actionName>
34+
<packagings>
35+
<packaging>jar</packaging>
36+
</packagings>
37+
<goals>
38+
<goal>process-classes</goal>
39+
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal>
40+
</goals>
41+
<properties>
42+
<exec.args>-classpath %classpath ${packageClassName}</exec.args>
43+
<exec.executable>java</exec.executable>
44+
</properties>
45+
</action>
46+
</actions>

pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
<groupId>com.steamgriddb</groupId>
5+
<artifactId>java-steamgriddb</artifactId>
6+
<version>1.0</version>
7+
<packaging>jar</packaging>
8+
<dependencies>
9+
<dependency>
10+
<groupId>org.json</groupId>
11+
<artifactId>json</artifactId>
12+
<version>20180813</version>
13+
</dependency>
14+
</dependencies>
15+
<properties>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
<maven.compiler.source>11</maven.compiler.source>
18+
<maven.compiler.target>11</maven.compiler.target>
19+
</properties>
20+
<repositories>
21+
<repository>
22+
<id>jitpack.io</id>
23+
<url>https://jitpack.io</url>
24+
</repository>
25+
</repositories>
26+
</project>
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.steamgriddb;
2+
3+
/**
4+
* Represents a Author as found on SteamGridDB.com
5+
*
6+
* @author mpaterakis
7+
*/
8+
public class Author {
9+
10+
/*
11+
* Fields
12+
*/
13+
private String name = "";
14+
private String steam64 = "";
15+
private String avatar = "";
16+
17+
/**
18+
* Constructor for Author.
19+
*
20+
* @param name The Author's name
21+
* @param steam64 The Author's Steam64 ID
22+
* @param avatar The Author's avatar URL
23+
*/
24+
public Author(String name, String steam64, String avatar) {
25+
this.name = name;
26+
this.steam64 = steam64;
27+
this.avatar = avatar;
28+
}
29+
30+
/**
31+
* Get the Author's name.
32+
*
33+
* @return The Author's name
34+
*/
35+
public String getName() {
36+
return name;
37+
}
38+
39+
/**
40+
* Get the Author's Steam64 ID.
41+
*
42+
* @return The Author's Steam64 ID
43+
*/
44+
public String getSteam64() {
45+
return steam64;
46+
}
47+
48+
/**
49+
* Get the Author's avatar URL.
50+
*
51+
* @return The Author's avatar URL
52+
*/
53+
public String getAvatar() {
54+
return avatar;
55+
}
56+
57+
58+
}

0 commit comments

Comments
 (0)