-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2d7c029
Showing
12 changed files
with
1,217 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Manos Paterakis | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# Java-SteamGridDB | ||
A Java wrapper for SteamGridDB's API | ||
|
||
### Installation | ||
|
||
[](https://jitpack.io/#mpaterakis/java-steamgriddb) | ||
|
||
## Getting Started | ||
#### Get your API key | ||
[You can generate an API key on the preferences page.](https://www.steamgriddb.com/profile/preferences) | ||
|
||
#### Require the library into your project. | ||
```java | ||
import com.SteamGridDB.*; | ||
import com.SteamGridDB.Enums.*; | ||
import com.SteamGridDB.Connection.*; | ||
``` | ||
|
||
#### Initialize the SGDBConnectionManager using your API key and the API base uri | ||
```java | ||
SGDBConnectionManager.initialize("https://www.steamgriddb.com/api/v2", "myAuthKey"); | ||
``` | ||
|
||
#### Search for a game: | ||
```java | ||
// Get an ArrayList of games that match the search term | ||
var games = Search.searchGamesByName("cyberpunk"); | ||
|
||
// Get a JSONObject containing the response from the API [Can be converted to string using .toString()] | ||
var gamesJson = Search.searchGamesByNameJSON("cyberpunk"); | ||
``` | ||
|
||
#### Get a game object without searching: | ||
```java | ||
// Get a Game using a GameId | ||
var game = Game.getGameByGameId(1234); | ||
|
||
// Get a Game using a SteamAppId | ||
var game = Game.getGameBySteamAppId(567890); | ||
|
||
// Get a Game using its constructor | ||
var game = new Game(567890, SGDBIdTypes.SteamAppId); | ||
``` | ||
|
||
#### Do something with a game object: | ||
```java | ||
// Get a Game's Name | ||
var gameName = game.getName(); | ||
|
||
// Get a Game's styles | ||
var stylesArray = game.getStyles(); | ||
``` | ||
|
||
#### Get some grids: | ||
```java | ||
// Get grids by game ID | ||
var grid = Grid.getGridsByGameId(1234); | ||
|
||
// Get grids by Steam App Id | ||
var grids = Grid.getGridsBySteamAppId(1234); | ||
|
||
// Alternatively, you can do it like this: | ||
var grids = Grid.getGridsById(1234, SGDBIdTypes.GameId); | ||
``` | ||
|
||
#### Filter the styles: | ||
```java | ||
// Create an SGDBStyles array | ||
SGDBStyles styles[] = {SGDBStyles.Alternate, SGDBStyles.NoLogo}; | ||
|
||
// Same as before, but using the styles filter | ||
var grid = Grid.getGridsByGameId(1234, styles); | ||
|
||
var grids = Grid.getGridsBySteamAppId(1234, styles); | ||
|
||
var grids = Grid.getGridsById(1234, SGDBIdTypes.GameId, styles); | ||
``` | ||
|
||
#### Do something with a grid object: | ||
```java | ||
// Get the first Grid's score | ||
var gridScore = grids.get(0).getScore(); | ||
|
||
// Get the same Grid's Author's username | ||
var authorName = grids.get(0).getAuthor().getName(); | ||
``` | ||
|
||
## Other methods | ||
#### Vote on grids: | ||
```java | ||
// Upvote the first grid of the game with ID 1234 | ||
var grid = Grid.getGridsByGameId(1234).get(0); | ||
grid.upvote(); | ||
|
||
// Downvote the same grid | ||
var grid = Grid.getGridsByGameId(1234).get(0); | ||
grid.upvote(); | ||
|
||
// Alternatively, use the Grid's ID (80 in this case) to vote: | ||
Grid.upvoteById(80); | ||
Grid.downvoteById(80); | ||
``` | ||
|
||
#### Upload a grid: | ||
```java | ||
// Upload a blurred grid to Half-Life 2 (2254) | ||
Grid.upload(2254, SGDBStyles.Blurred, "path/of/image.img"); | ||
``` | ||
|
||
#### Delete grids: | ||
```java | ||
// Delete a grid by ID | ||
Grid.deleteByGridID(gameID); | ||
|
||
// Delete multiple grids by ID | ||
var gameIDs = {123, 456}; | ||
Grid.deleteByGridIDs(gameIDs); | ||
|
||
// Delete a Grid object | ||
var grid = Grid.getGridsByGameId(1234).get(0); | ||
grid.delete(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<actions> | ||
<action> | ||
<actionName>run</actionName> | ||
<packagings> | ||
<packaging>jar</packaging> | ||
</packagings> | ||
<goals> | ||
<goal>process-classes</goal> | ||
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal> | ||
</goals> | ||
<properties> | ||
<exec.args>-classpath %classpath ${packageClassName}</exec.args> | ||
<exec.executable>java</exec.executable> | ||
</properties> | ||
</action> | ||
<action> | ||
<actionName>debug</actionName> | ||
<packagings> | ||
<packaging>jar</packaging> | ||
</packagings> | ||
<goals> | ||
<goal>process-classes</goal> | ||
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal> | ||
</goals> | ||
<properties> | ||
<exec.args>-agentlib:jdwp=transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath ${packageClassName}</exec.args> | ||
<exec.executable>java</exec.executable> | ||
<jpda.listen>true</jpda.listen> | ||
</properties> | ||
</action> | ||
<action> | ||
<actionName>profile</actionName> | ||
<packagings> | ||
<packaging>jar</packaging> | ||
</packagings> | ||
<goals> | ||
<goal>process-classes</goal> | ||
<goal>org.codehaus.mojo:exec-maven-plugin:1.5.0:exec</goal> | ||
</goals> | ||
<properties> | ||
<exec.args>-classpath %classpath ${packageClassName}</exec.args> | ||
<exec.executable>java</exec.executable> | ||
</properties> | ||
</action> | ||
</actions> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<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"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>com.steamgriddb</groupId> | ||
<artifactId>java-steamgriddb</artifactId> | ||
<version>1.0</version> | ||
<packaging>jar</packaging> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.json</groupId> | ||
<artifactId>json</artifactId> | ||
<version>20180813</version> | ||
</dependency> | ||
</dependencies> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<maven.compiler.source>11</maven.compiler.source> | ||
<maven.compiler.target>11</maven.compiler.target> | ||
</properties> | ||
<repositories> | ||
<repository> | ||
<id>jitpack.io</id> | ||
<url>https://jitpack.io</url> | ||
</repository> | ||
</repositories> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package com.steamgriddb; | ||
|
||
/** | ||
* Represents a Author as found on SteamGridDB.com | ||
* | ||
* @author mpaterakis | ||
*/ | ||
public class Author { | ||
|
||
/* | ||
* Fields | ||
*/ | ||
private String name = ""; | ||
private String steam64 = ""; | ||
private String avatar = ""; | ||
|
||
/** | ||
* Constructor for Author. | ||
* | ||
* @param name The Author's name | ||
* @param steam64 The Author's Steam64 ID | ||
* @param avatar The Author's avatar URL | ||
*/ | ||
public Author(String name, String steam64, String avatar) { | ||
this.name = name; | ||
this.steam64 = steam64; | ||
this.avatar = avatar; | ||
} | ||
|
||
/** | ||
* Get the Author's name. | ||
* | ||
* @return The Author's name | ||
*/ | ||
public String getName() { | ||
return name; | ||
} | ||
|
||
/** | ||
* Get the Author's Steam64 ID. | ||
* | ||
* @return The Author's Steam64 ID | ||
*/ | ||
public String getSteam64() { | ||
return steam64; | ||
} | ||
|
||
/** | ||
* Get the Author's avatar URL. | ||
* | ||
* @return The Author's avatar URL | ||
*/ | ||
public String getAvatar() { | ||
return avatar; | ||
} | ||
|
||
|
||
} |
Oops, something went wrong.