Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mrbean355/dota2-gsi
JVM library for receiving game state updates from Dota 2.
https://github.com/mrbean355/dota2-gsi
dota2 dota2-api dota2-bot dota2-data dota2-modding
Last synced: 3 days ago
JSON representation
JVM library for receiving game state updates from Dota 2.
- Host: GitHub
- URL: https://github.com/mrbean355/dota2-gsi
- Owner: MrBean355
- License: apache-2.0
- Created: 2020-10-11T11:31:19.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-04-27T18:16:32.000Z (7 months ago)
- Last Synced: 2024-10-11T12:44:24.093Z (about 1 month ago)
- Topics: dota2, dota2-api, dota2-bot, dota2-data, dota2-modding
- Language: Kotlin
- Homepage: https://mrbean355.github.io/dota2-gsi/
- Size: 1.38 MB
- Stars: 11
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Dota 2 - Game State Integration - JVM
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.mrbean355/dota2-gsi/badge.png)](https://search.maven.org/artifact/com.github.mrbean355/dota2-gsi)
[![Documentation](https://img.shields.io/badge/KDoc-GitHub%20Pages-B125EA)](https://mrbean355.github.io/dota2-gsi)
[![Build project](https://github.com/MrBean355/dota2-gsi/actions/workflows/build-project.yml/badge.svg?branch=main)](https://github.com/MrBean355/dota2-gsi/actions/workflows/build-project.yml)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=MrBean355_dota2-gsi&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=MrBean355_dota2-gsi)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=MrBean355_dota2-gsi&metric=coverage)](https://sonarcloud.io/summary/new_code?id=MrBean355_dota2-gsi)This is a JVM library that **aims to make working with Dota 2's Game State Integration simple**. Game State
Integration (GSI) is a feature built into Dota 2 that allows us to ask Dota to periodically send us information on the
current game state. You can find more information
on [Valve's Developer Wiki for CS:GO](https://developer.valvesoftware.com/wiki/Counter-Strike:_Global_Offensive_Game_State_Integration)
(the same applies to Dota 2).In the simplest terms, the library starts up a local server which listens for game state information from the Dota 2
client. It then deserializes this JSON data into type-safe objects for developers to work with.**Why use a library for this?** The JSON data that Dota sends can vary significantly in structure, which makes simple
parsing very tricky. Specifically, the structure is different when the Dota client is playing a match compared to when
it is spectating a match. This library aims to remove this worry from the developer, and simply exposes type-safe
objects to work with.## Getting Set Up
1. [**Set up your Dota 2 client**](https://github.com/MrBean355/dota2-gsi/wiki/Dota-2-Setup) to send game state
information to your program.
2. [**Add the dependency**](https://github.com/MrBean355/dota2-gsi/wiki/Library-Guide#add-the-dependency) to your
project.## Sample Code
### Kotlin
```kotlin
fun main() {
// Create a server which listens on the port configured during Dota setup:
GameStateServer(44444)
// Register one or more listeners:
.setPlayingListener { gameState ->
// Do something with the received gameState object:
val clockTime = gameState.map?.clockTime
println("The clock time is $clockTime seconds.")
}
// Start the server, blocking the thread so the program doesn't immediately exit:
.start() // Alternatively startAsync() will not block the thread.
}
```### Java
```java
public class GsiDemo {public static void main(String[] args) {
// Create a server which listens on the port configured during Dota setup:
GameStateServer.create(44444)
// Register one or more listeners:
.setPlayingListener(gameState -> {
// Do something with the received gameState object:
if (gameState.getMap() != null) {
int clockTime = gameState.getMap().getClockTime();
System.out.println("The clock time is " + clockTime + " seconds.");
}
})
// Start the server, blocking the thread so the program doesn't immediately exit:
.start(); // Alternatively startAsync() will not block the thread.
}
}
```## Additional Resources
- The project's [Wiki](https://github.com/MrBean355/dota2-gsi/wiki).
- The full [API reference](https://mrbean355.github.io/dota2-gsi).
- The
[demo project](https://github.com/MrBean355/dota2-gsi/tree/main/demo/src/main/java/com/github/mrbean355/dota2/demo)
has some more involved examples.## Compatibility
The library requires at least **Java 8** to compile.
Additionally, the library depends on a few third party dependencies. If you use older versions of these dependencies in
your project, they will probably be transitively upgraded to the version used by this library, so beware.| Library version | Kotlin version | Ktor version | KotlinX Serialization version |
|-----------------|----------------|--------------|-------------------------------|
| 2.4.x | 1.8.22 | 2.3.5 | 1.5.1 |
| 2.3.x | 1.8.21 | 2.3.0 | 1.5.0 |
| 2.2.x | 1.8.20 | 2.3.0 | 1.5.0 |
| 2.1.x | 1.7.10 | 2.0.3 | 1.3.3 |
| 2.0.x | 1.7.10 | 2.0.3 | 1.3.3 |
| 1.2.x | 1.7.10 | 2.0.3 | - |
| 1.1.x | 1.5.31 | 1.6.4 | - |
| 1.0.x | 1.4.21 | 1.4.3 | - |## Snapshots
Snapshots of the current in-development release are also published to Maven Central. You can use them in your project as
well, but are likely to be unstable. You can find
[more information on the Wiki](https://github.com/MrBean355/dota2-gsi/wiki/Library-Guide#snapshots).## Feedback
Feedback on the library is always welcomed and appreciated! Whether it's bug reports, suggestions, or even just
questions, please let me know by creating an [issue](https://github.com/MrBean355/dota2-gsi/issues) or
[discussion](https://github.com/MrBean355/dota2-gsi/discussions) on this GitHub repository.[![SonarCloud](https://sonarcloud.io/images/project_badges/sonarcloud-white.svg)](https://sonarcloud.io/summary/new_code?id=MrBean355_dota2-gsi)