Skip to content

Commit

Permalink
Added project
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelvcaetano committed Apr 14, 2018
1 parent 0edb232 commit edb8f48
Show file tree
Hide file tree
Showing 97 changed files with 4,252 additions and 0 deletions.
19 changes: 19 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Eclipse
.classpath
.project
.settings/

# Intellij
.idea/
*.iml
*.iws

# Mac
.DS_Store

# Maven
log/
target/

# Build
out/
42 changes: 42 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# IL-2 Integrator

The IL-2 integrator aims to provide a common point of integration for the game series IL-2 Great
Battles that third party tools can use to improve the game experience.

## Features
* Career integration
* PWCG integration

## Installing
To install the integrator, simply go the the Releases, download the latest version and extract it on
the root directory of your game installation. Then, launch it whenever you want to use its
functionalities. It is not necessary to launch the game through the integrator as this is just a
utility. However, the application must be left running in the background.

## Integration into third party tools
Feel free to use the functionalities provided by the integrator in any third party tool that you
might be developing. As a starting point, read the README inside the core module to have a basic
understanding of the system. Then, read about each service that you intend to use and the
functionalities that they provide. Finally, read about the interface that you decide to use to learn
how you can connect to the integrator and the defined protocol.

## Available interfaces
* HTTP - available through port 8080
* UDP - available through port 25005

## Contributing
Contributions are welcome, specially with new services and interfaces. If you need any specific
functionality for your tool, feel free to open an issue or create a pull request with the
implementation.

When creating pull requests, always follow the style conventions that are found currently in the
project.

Tests are always welcome, even though they are not always easy to implement.

## Building
To build the project, Maven is required. From the root folder simply run:

`mvn package`

The final binaries can be found inside the folder "target" of both the `cli` and `gui` modules.
13 changes: 13 additions & 0 deletions cli/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Eclipse
.classpath
.project
.settings/

# Intellij
.idea/
*.iml
*.iws

# Maven
log/
target/
12 changes: 12 additions & 0 deletions cli/README.MD
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# IL-2 Integrator CLI
The CLI provides an interface (not a standard integrator interface) for easier testing during
development and is not intended to be released to the public.
When running, the CLI has no registered interfaces by default. They can, however, be added during
development for testing purposes.

## Using the tool
Commands are typed into the command line using the following format:

`<service> <command> [arg=val1 arg2=val2]`

To close the integrator you can type `exit`.
26 changes: 26 additions & 0 deletions cli/gen_exe_cli.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<launch4jConfig>
<dontWrapJar>false</dontWrapJar>
<headerType>console</headerType>
<jar>target\il2integrator-cli.jar</jar>
<outfile>target\IL2 Integrator CLI.exe</outfile>
<errTitle></errTitle>
<cmdLine></cmdLine>
<chdir>.</chdir>
<priority>normal</priority>
<downloadUrl>http://java.com/download</downloadUrl>
<supportUrl></supportUrl>
<stayAlive>false</stayAlive>
<restartOnCrash>false</restartOnCrash>
<manifest></manifest>
<icon></icon>
<jre>
<path></path>
<bundledJre64Bit>false</bundledJre64Bit>
<bundledJreAsFallback>false</bundledJreAsFallback>
<minVersion>1.8.0</minVersion>
<maxVersion></maxVersion>
<jdkPreference>preferJre</jdkPreference>
<runtimeBits>64/32</runtimeBits>
</jre>
</launch4jConfig>
87 changes: 87 additions & 0 deletions cli/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<?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>

<artifactId>cli</artifactId>
<version>1.0</version>

<parent>
<groupId>me.magnum.il2integrator</groupId>
<artifactId>il2integrator</artifactId>
<version>1.0</version>
</parent>

<build>
<finalName>cli</finalName>

<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<configuration>
<finalName>il2integrator-cli</finalName>
<appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<mainClass>me.magnum.il2mapintegrator.cli.Main</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>

<plugin>
<groupId>com.akathist.maven.plugins.launch4j</groupId>
<artifactId>launch4j-maven-plugin</artifactId>
<version>1.7.21</version>
<executions>
<execution>
<id>l4j-cli</id>
<phase>package</phase>
<goals>
<goal>launch4j</goal>
</goals>
<configuration>
<infile>${project.basedir}/gen_exe_cli.xml</infile>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>me.magnum.il2integrator</groupId>
<artifactId>core</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>me.magnum.il2integrator</groupId>
<artifactId>career</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>me.magnum.il2integrator</groupId>
<artifactId>pwcg</artifactId>
<version>1.0</version>
</dependency>
<dependency>
<groupId>me.magnum.il2integrator</groupId>
<artifactId>http</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
3 changes: 3 additions & 0 deletions cli/src/main/java/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Manifest-Version: 1.0
Main-Class: me.magnum.il2mapintegrator.cli.Main

109 changes: 109 additions & 0 deletions cli/src/main/java/me/magnum/il2mapintegrator/cli/DebugThread.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
package me.magnum.il2mapintegrator.cli;

import com.google.gson.Gson;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import me.magnum.il2mapintegrator.core.IL2Integrator;
import me.magnum.il2mapintegrator.core.Logger;
import me.magnum.il2mapintegrator.core.entities.CommandRequest;
import me.magnum.il2mapintegrator.core.entities.Response;

public class DebugThread extends Thread {
private static final Pattern commandSplitPattern = Pattern.compile("([^\"]\\S*|\".+?\")\\s*");

private Gson gson;
private IL2Integrator il2Integrator;
private AtomicBoolean running;

public DebugThread(IL2Integrator il2Integrator) {
this.il2Integrator = il2Integrator;
this.gson = new Gson();
this.running = new AtomicBoolean(false);
}

@Override
public void run() {
this.running.set(true);

BufferedReader inputReader = new BufferedReader(new InputStreamReader(System.in));
while (this.running.get()) {
String input;
try {
while (!inputReader.ready() && this.running.get()) {
try {
sleep(100);
} catch (InterruptedException e) {
Logger.e(e);
}
}
if (!this.running.get())
return;
input = inputReader.readLine();
} catch (IOException e) {
Logger.e(e);
continue;
}

if (input.equals("exit")) {
this.running.set(false);
break;
}

CommandRequest request = this.createRequest(input);
if (request == null) {
System.out.println("Invalid syntax");
continue;
}

Response response = this.il2Integrator.processCommand(request);

String responseString = this.gson.toJson(response);
System.out.println(responseString);
}
}
private CommandRequest createRequest(String data) {
List<String> parts = new ArrayList<>();

Matcher matcher = commandSplitPattern.matcher(data);
while (matcher.find()) {
String match = matcher.group(1);
if (match.length() == 0)
continue;

if (match.charAt(0) == '\"')
match = match.replace("\"", "");

parts.add(match);
}

if (parts.size() < 2)
return null;

Map<String, String> args = new HashMap<>();
for (int i = 2; i < parts.size(); i++) {
String part = parts.get(i);
String[] arg = part.split("=");
if (arg.length != 2)
return null;

args.put(arg[0], arg[1]);
}

CommandRequest request = new CommandRequest();
request.service = parts.get(0);
request.command = parts.get(1);
request.args = args;

return request;
}
}
28 changes: 28 additions & 0 deletions cli/src/main/java/me/magnum/il2mapintegrator/cli/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package me.magnum.il2mapintegrator.cli;

import me.magnum.il2mapintegrator.career.CareerService;
import me.magnum.il2mapintegrator.core.IL2IntegratorBuilder;
import me.magnum.il2mapintegrator.core.IL2Integrator;
import me.magnum.il2mapintegrator.core.Logger;
import me.magnum.il2mapintegrator.pwcg.PWCGService;

public class Main {
public static void main(String[] args) {
IL2Integrator il2Integrator = new IL2IntegratorBuilder()
.addService(new CareerService())
.addService(new PWCGService())
.build();

il2Integrator.start();

DebugThread debugThread = new DebugThread(il2Integrator);
debugThread.start();
try {
// Wait for the debug thread to exit
debugThread.join();
} catch (InterruptedException e) {
Logger.e(e);
}
il2Integrator.stop();
}
}
13 changes: 13 additions & 0 deletions core/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Eclipse
.classpath
.project
.settings/

# Intellij
.idea/
*.iml
*.iws

# Maven
log/
target/
Loading

0 comments on commit edb8f48

Please sign in to comment.