Skip to content

Commit

Permalink
Add shade plugin and default config
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiyotoko committed Apr 25, 2024
1 parent ff15c1a commit 8f53cc3
Show file tree
Hide file tree
Showing 4 changed files with 130 additions and 33 deletions.
67 changes: 60 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<h1 align="center">Seekers Server</h1>

<p align="center">
<a href="https://jitpack.io/#seekers-dev/seekers-server">
<img alt="Jitpack" src="https://jitpack.io/v/seekers-dev/seekers-server.svg">
</a>
<a href="https://github.com/seekers-dev/seekers-java/actions/workflows/github-code-scanning/codeql">
<img src="https://github.com/seekers-dev/seekers-java/actions/workflows/github-code-scanning/codeql/badge.svg" alt="CodeQL">
</a>
Expand All @@ -17,17 +20,67 @@

In seekers, AIs compete against each other with the aim of scoring as many points as possible. This project is competition-oriented for students.

## Setup
## Getting started

| Folder | Purpose |
|:---------:|---------------------------------------|
| `dist` | Distribution binaries for the clients |
| `players` | Bot files from the players |
| `plugins` | Loading plugin jar files |
| `results` | Save tournament results |
Please note that at least java 11 is required.

### Installation

Get a jar file from the release or build it on your own.

#### From release

There is currently no official release available, however you can check out [Jitpack](https://jitpack.io/#seekers-dev/seekers-server)
for snapshot builds.

#### Build it on your own

First get this repo locally. You can download the zip file or fork and clone it. You can build the jar with the following command:

```shell
bash mvnw install
```

That's it! You can find the jar file in the `target` folder. Please note that for execution you will need the file with
the uber classifier.

### Run it

You can run the jar file with the following command:

```shell
java -jar seekers-server-*.*.*.jar
```

If you start the server for the first time, the following file and folders will be created:

| Folder | Purpose |
|:------------:|---------------------------------------|
| `config.ini` | Config file for changing the settings |
| `players` | Bot files from the players |
| `plugins` | Loading plugin jar files |
| `results` | Save tournament results |

Before the server starts, the app checks first if all listed paths exist. If a path does not exist, it will be created.
Then it will launch all plugins.

## Config

In the `config.ini`, you can set properties for the game and your plugins. Note that all plugins have their own section.
For example, the section of the python plugin is `[python-plugin]`. The name of the section is equivalent to the id of
the plugin. Please note that the config file of the seekers-py repo and this config file are interchangeable. If you
have already altered your config file for python, you can simply reuse it for the server.

## Players

## Plugins

## Results

## Structure

This is the class diagram of important types in this program:

```mermaid
classDiagram
Entity: update()
Expand Down
55 changes: 33 additions & 22 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<description>Server for the seekers game.</description>
<inceptionYear>2022</inceptionYear>
<version>0.0.1</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.mainClass>org.seekers.Launcher</project.mainClass>
Expand All @@ -15,13 +16,27 @@
<maven.compiler.target>${project.javaVersion}</maven.compiler.target>
<maven.compiler.release>${project.javaVersion}</maven.compiler.release>
</properties>

<contributors>
<contributor>
<name>Karl Zschiebsch</name>
</contributor>
<contributor>
<name>Jonas Endter</name>
</contributor>
<contributor>
<name>Martin Wille</name>
</contributor>
</contributors>

<repositories>
<!-- Use JitPack for snapshot builds -->
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<!-- Graphics -->
<dependency>
Expand Down Expand Up @@ -76,8 +91,26 @@
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.2</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>uber</shadedClassifierName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-wrapper-plugin</artifactId>
Expand All @@ -93,27 +126,6 @@
<release>${project.javaVersion}</release>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.3.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.6.1</version>
<executions>
<execution>
<phase>prepare-package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/lib</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand All @@ -122,7 +134,6 @@
<archive>
<manifest>
<addClasspath>true</addClasspath>
<classpathPrefix>lib/</classpathPrefix>
<mainClass>${project.mainClass}</mainClass>
<packageName>seekers</packageName>
</manifest>
Expand Down
12 changes: 8 additions & 4 deletions src/main/java/org/seekers/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
* Creates the server and application for the {@code SeekersServer}. Loads and unloads plugins. Loads the If the stage is closed,
Expand Down Expand Up @@ -63,10 +64,12 @@ public class App extends Application {
*/
@Override
public void init() throws IOException {
config.load(new File("config.ini"));

for (String folder : List.of("players", "plugins", "results")) {
Path path = Path.of(folder);
Path path = Path.of("config.ini");
if (!Files.exists(path)) {
Files.copy(Objects.requireNonNull(getClass().getResourceAsStream("config.ini")), path);
}
for (String folder : new String[] {"players", "plugins", "results"}) {
path = Path.of(folder);
if (!Files.exists(path)) {
try {
Files.createDirectory(path);
Expand All @@ -76,6 +79,7 @@ public void init() throws IOException {
}
}

config.load(new File("config.ini"));
manager.loadPlugins();
manager.startPlugins();

Expand Down
29 changes: 29 additions & 0 deletions src/main/resources/org/seekers/config.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[global]
auto-play=false
playtime=2000
players=2
seekers=5
goals=5

[map]
width=768
height=768

[camp]
width=55.0
height=55.0

[seeker]
magnet-slowdown=0.2
disabled-time=250.0
radius=10.0
mass=1.0
thrust=0.1
friction=0.02

[goal]
scoring-time=100.0
radius=6.0
mass=0.5
thrust=0.1
friction=0.02

0 comments on commit 8f53cc3

Please sign in to comment.