Java Player Skeleton

The Java Player Skeleton is based on Spring Boot. It is a good starting point for Java developers. You find it here. If you want to use it, fork this repo to your own repo, and start working.

Player Skeleton with Java and Spring Boot

This is a player skeleton for the microservice dungeon, which is written in Java using Spring Boot. You can use this player as a basis for your own player.

Authors: Tobias Hund, Stefan Bente

Requirements:

  • Java 17

Preparation

To use this skeleton as the base for your player development, you need to accomplish the following steps.

First, fork this repository and create a new repository under the Player Teams subgroup (or in any other Git location). The fork should named after your desired player name, for example player-constantine.

Now you need to add your player-name to a few files. The required places are marked using TODO comments. Update the files in helm-chart/Chart.yaml, pom.xml, src/resources/application.properties and .gitlab-ci.yml.

Configuration

The player can be configured using environment variables:

Environment Variable Default
RABBITMQ_HOST localhost
RABBITMQ_PORT 5672
RABBITMQ_USER admin
RABBITMQ_PASSWORD admin
GAME_HOST http://localhost:8080
PLAYER_NAME player-skeleton-java-springboot
PLAYER_EMAIL player-skeleton-java-springboot@example.com
LOGGING_LEVEL debug

Event Listening

The skeleton player makes use of a single messaging queue for all events. It automatically listens on the player-owned queue for all events and deserializes them. Afterwards the events are dispatched using the in-memory eventing system provided by the Spring framework. See the RabbitMQ Listener implementation and exemplary in-memory event listeners.

Dev Mode

The player can be started dev mode. This mode creates and starts a game automatically for you, when you start the player. No manual requests are required. This is REALLY helpful for local development, as you can start the player and the game with a single command, from within your IDE.

This feature is ONLY FOR LOCAL DEVELOPMENT. To enable it, activate the dev Spring Boot profile. You can achieve it over the command line by setting the spring.profiles.active property or instruct your IDE (e.g IntelliJ) to activate it.

Enable Dev Mode in IntelliJ Ultimate

1. Create a Spring Boot run configuration for your main class (if not already done)

Easiest way is to right click on the main class thkoeln.dungeon.player.DungeonPlayerMainApplication and select “Run DungeonPlayerMainApplication …” in the context menu.

Create Spring Boot run configuration

2. Open the run configuration editor …

Open the run configuration editor

3. … and add the dev profile to the active profiles

Add dev profile

Tests

The player skeleton contains a number of tests, which can be enhanced to test your own player implementation. The fall into two categories, “unit tests” and “integration tests”. For the distinction between these two, you can e.g. refer to this video. In short:

  • Unit tests are fast and test a single class or method in isolation. They are located in the src/test/unittest folder.
  • Integration tests are running the Spring framework, and mock the core services (i.e. the Microservice Dungeon Local Dev Env based on Docker Compose is not required - and should also not run, since this would interfere with the test mocks.
    They are located in the src/test/integrationtest folder.

This separation is important, since unit tests are fast and can be run on every change, while integration tests are slower and should only be run before a commit or push.

Configure the test roots in IntelliJ

If you are using IntelliJ, you need to configure the test roots for the unit and integration tests.

1. No test roots defined

No test roots defined

You can see that both the unit and integration test folders are not marked as test roots (the folder icons are grey, not green).

2. Open the project structure dialog

Open the project structure dialog

3. Select the “Modules” entry …

Select the modules entry

4. Remove any old test root entry

Select the modules entry

If there is an old test root entry like src\test\java, remove it by selecting it and clicking the “remove” icon.

5. Add the integrationtest and the unittest roots as test roots

Select the modules entry
Last modified February 4, 2025: fix go & npm dependencies (8ff1fa0)