Giter VIP home page Giter VIP logo

jgsi's Introduction

Java Game State Integration (CSGO)

Java Game State Integration is a library that can be used with CSGO's gamestate integration.

The API needs documenting, and expanding on (Im not sure ive gotten all the values that the game provides).

Using with gradle

repositories {
    mavenCentral()
	maven {
		name "modmuss50"
		url 'http://maven.modmuss50.me'
	}
}

dependencies {
    compile 'me.modmuss50:jgsi:+'
}

How to use

Basic example

import me.modmuss50.jgsi.api.GameStateIntegration;
import me.modmuss50.jgsi.api.models.GameState;

import java.io.IOException;

public class JavaGameStateIntegrationTest {

	public static void main(String[] args) {
		GameStateIntegration
			.create()
			.onUpdate(JavaGameStateIntegrationTest::handle)
			.start();
	}

	private static void handle(GameState gameState){
		if(gameState.getMap() != null){
			System.out.println(gameState.getMap().getName());
		}
	}

}

This is a basic example, that calls handle everytime the game updates the state. This test app is also included in src/test/java.

Round Tracker

import me.modmuss50.jgsi.api.GameStateIntegration;
import me.modmuss50.jgsi.api.RoundTracker;

import java.io.IOException;

public class JavaGameStateIntegrationRoundTrackerExample {

	public static void main(String[] args) {
		GameStateIntegration integration = GameStateIntegration.create().start();
		RoundTracker tracker = RoundTracker.create(integration);
	
		tracker.streamRounds().forEach(gameState -> System.out.println("Round " + gameState.getMap().getRound()));
		System.out.println("Current round: " + tracker.getCurrentRound());
	}

}

The round tracker can be used to access the GameSate of any past rounds, as well as the current round, this is useful when you want to create stats based of the history of the player stats.

Setting up the game

The following needs to be placed into a file called gamestate_integration_java.cfg located in steamapps\common\Counter-Strike Global Offensive\csgo\cfg

"GameSate Integration"
{
 "uri" "http://localhost:8181"
 "timeout" "5.0"
 "buffer"  "1"
 "throttle" "0.1"
 "heartbeat" "30.0"
 "auth"
 {
   "token" "TestPassword"
 }
 "data"
 {
   "provider"            	"1"
   "map"                 	"1"
   "round"               	"1"
   "player_id"           	"1"
   "allplayers_id"       	"1"     
   "player_state"        	"1"      
   "allplayers_state"    	"1"      
   "allplayers_match_stats" "1"  
   "allplayers_weapons"  	"1"      
   "allplayers_position" 	"1"      
   "phase_countdowns"    	"1"      
   "allgrenades"    		"1" 
   "bomb" 					"1"  
 }
}

The auth token can be validated by using validateAuth

jgsi's People

Contributors

modmuss50 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.