Skip to content

Commit

Permalink
Publishing the source code of the project
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio112009 committed Feb 2, 2021
0 parents commit cd9124c
Show file tree
Hide file tree
Showing 16 changed files with 1,384 additions and 0 deletions.
149 changes: 149 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
# Created by .ignore support plugin (hsz.mobi)
### Eclipse template
.metadata
bin/
tmp/
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.recommenders

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# PyDev specific (Python IDE for Eclipse)
*.pydevproject

# CDT-specific (C/C++ Development Tooling)
.cproject

# CDT- autotools
.autotools

# Java annotation processor (APT)
.factorypath

# PDT-specific (PHP Development Tools)
.buildpath

# sbteclipse plugin
.target

# Tern plugin
.tern-project

# TeXlipse plugin
.texlipse

# STS (Spring Tool Suite)
.springBeans

# Code Recommenders
.recommenders/

# Annotation Processing
.apt_generated/
.apt_generated_test/

# Scala IDE specific (Scala & Java development for Eclipse)
.cache-main
.scala_dependencies
.worksheet

# Uncomment this line if you wish to ignore the project description file.
# Typically, this file would be tracked if it contains build/dependency configurations:
#.project



### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser




### Project escape directories/files
/.idea/
/target/
*.iml

# Making private tests
/src/test/java/com/antonio112009/steam4j/privatetest/
Notes.txt
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2020 Anton Rogalskiy and Steam4J contributors

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.
158 changes: 158 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
add Java 15v
add MIT Lisence
add ..


# Steam4J
Steam4J is an open-source project that strives provides full wrapping of game server queries.

## Navigation

1. [Dependencies](##Dependencies)
1. [Dependencies](##Features)
1. [Dependencies](##Installation)


##Dependencies
This project requires JDK 11+
Maven dependencies in the project:
* [Lombok](https://github.com/rzwitserloot/lombok): 1.18.16

##Features
The list of the features currently implemented in the project:
* [Rcon](https://developer.valvesoftware.com/wiki/Source_RCON_Protocol):
* Authentication to server with IP and Port
* Executing commands to the server and receiving answer
* Receiving commands from the server **without sending commands**. Listing to game console
* Support of multi-package answers
* [Server Queries](https://developer.valvesoftware.com/wiki/Server_queries)
* A2S_INFO
* A2S_PLAYER
* A2S_RULES
* A2S_PING and A2S_SERVERQUERY_GETCHALLENGE are depricated

##Installation
Download project from release page of the project

or

Add dependency to your project manager
**Maven**:
```xml
<dependency>
<artefactId>com.antonio112009</artefactId>
<groupId>steam4j</groupId>
<version>1.0.0</version>
</dependency>
```

## Code examples

### Rcon examples:
Execute single command:
```java
public class SendingSingleCommand {

public static void main(String[] args) {
Rcon rcon = new Rcon("0.0.0.0", 21114);
rcon.openStream();
boolean isAuthenticated = rcon.authenticate(password);
if(isAuthenticated) {
String answerFromServer = rcon.sendCommand("ListPlayers");
System.out.println("Answer: " + answerFromServer);
}
rcon.closeStream(); //optional if it's in the end of the program
}

}
```

Execute multiple command:
```java
public class SendingMultipleCommand {

public static void main(String[] args) {
Rcon rcon = new Rcon("0.0.0.0", 21114);
rcon.openStream();
boolean isAuthenticated = rcon.authenticate(password);
if(isAuthenticated) {
System.out.println("Answer1: " + rcon.sendCommand("ListPlayers"));
System.out.println("Answer2: " + rcon.sendCommand("GetCurrentScore"));
System.out.println("Answer3: " + rcon.sendCommand("ChatToAll Hello world!"));
System.out.println("Answer: " + answerFromServer);
}
rcon.closeStream(); //optional if it's in the end of the program
}

}
```

Receiving non-stop messages from a server (no execution of commands). Usually console logs:
```java
public class ReceiveServerLogs {

public static void main(String[] args) {
Rcon rcon = new Rcon("0.0.0.0", 21114);
rcon.openStream();
boolean isAuthenticated = rcon.authenticate(password);
while (isAuthenticated) {
try {
System.out.println("Answer: " + rcon.receivingServerMessages());
} catch (IOException e) {
e.printStackTrace();
rcon.closeStream(); //optional if it's in the end of the program
break;
}
}
}

}
```

### Server Queries (A2S):
All objects represent response format of data that are shown in details on the [official Valve developer page](https://developer.valvesoftware.com/wiki/Server_queries).

### Server information
Getting information of the server. Read more [here](https://developer.valvesoftware.com/wiki/Server_queries#A2S_INFO)
```java
public class GetServerInformation {

public static void main(String[] args) {
A2s a2s = new A2S("0.0.0.0", 27166);
ServerInfo serverInfo = a2S.getServerInfo();
System.out.println("Result:\n" + serverInfo.toString());
}

}
```

### Server players
Getting information of the server. Read more [here](https://developer.valvesoftware.com/wiki/Server_queries#A2S_PLAYER)
```java
public class GetServerInformation {

public static void main(String[] args) {
A2s a2s = new A2S("0.0.0.0", 27166);
Players players = a2S.getPlayers();
System.out.println("Result:\n" + players.toString());
}

}
```

### Server rules
Getting information of the server. Read more [here](https://developer.valvesoftware.com/wiki/Server_queries#A2S_RULES)
```java
public class GetServerInformation {

public static void main(String[] args) {
A2s a2s = new A2S("0.0.0.0", 27166);
Rules rules = a2S.getRules();
System.out.println("Result:\n" + rules.toString());
}

}
```

## Contribution
The contribution template and format is currently under development. Anyway, you are welcome to contribute this project.
55 changes: 55 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?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.antonio112009</groupId>
<artifactId>steam4j</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.16</version>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>5.7.0</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>11</source>
<target>11</target>
</configuration>
</plugin>
</plugins>
</build>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Antonio112009 Apache Maven Packages</name>
<url>https://maven.pkg.github.com/Antonio112009/Steam4J</url>
</repository>
</distributionManagement>
</project>
Loading

0 comments on commit cd9124c

Please sign in to comment.