Home›Java›Mods›Sleeping Server for Minecraft
ModsJava

Sleeping Server for Minecraft

Java mod listed for Minecraft 1.7–1.18. Download on the author's site.

⬇ Download on Spigot
Spring TCP Application for Starting a Minecraft Server

Introduction

This Spring Boot application is designed to start a Minecraft server when connections are detected on a specified TCP port (during server ping). The application listens on the port, and upon detecting a connection, it starts a Minecraft server by executing a specified script (either a PowerShell script on Windows or a shell script on Linux).

This app is supposed to work with a plugin that stops the server in case of 0 player connected.

Properties


Project Structure

ServiceConnectionHandler

The core of the application is the ServiceConnectionHandler class, annotated with @ComponenT and @Log4j2. This class handles the logic for listening to TCP connections, starting the Minecraft server, and managing processes.


Docker and Docker Compose Configuration

Structure

```
/path/to/project
├── docker-compose.yaml # Docker Compose configuration file
├── entrypoint.sh # Shell script to start the Minecraft server
├── server.jar # The Minecraft server jar file
├── [...] # Rest of your server files (worlds, plugins...)
└── app
└── starter.jar # The Spring Boot application jar file

```

Base image

The application is deployed using Docker. The base Docker image used is amazoncorretto:22-alpine-jdk, providing a lightweight environment for Java.

entrypoint.sh

The entrypoint.sh script is used to start the Minecraft server. The script simply executes the following command to start the server without a graphical interface (nogui):

``` sh
#!/bin/sh

java -jar /usr/src/myapp/server.jar nogui

```

This script is crucial as it allows the Spring Boot application to delegate the startup of the Minecraft server through a separate process, providing flexible process management.

docker-compose.yaml

``` yaml
version: '3.3' # Specifies the version of Docker Compose file format to use

services:
minecraft-survival-server: # The service name for the Minecraft server
image: amazoncorretto:22-alpine-jdk # The Docker image with Amazon Corretto JDK 22 on Alpine Linux
restart: always # Always restart the container if it stops
ports:
- 25565:25565 # Main Minecraft server port, accessible from the host
- 85:8123 # Port for additional services or plugins, like Dynmap
- 8100:8100 # Another port for additional services or plugins
- 25575:25575 # Port for RCON or other management tools
environment:
minecraft.listen.port: 25565 # Environment variable to set the port the application listens on
minecraft.script.start: /usr/src/myapp/entrypoint.sh # Path to the startup script for the Minecraft server
volumes:
- /path/to/your/minecraft/server:/usr/src/myapp # Maps the host directory to the container for server files and data persistence
working_dir: /usr/src/myapp # Sets the working directory inside the container
command: java -jar /usr/src/myapp/app/starter.jar # Command to run the Spring Boot application

```

Usage Instructions

Configure Minecraft Server Files


Set Up Docker Compose File


Start the Application with Docker Compose


``` sh
docker-compose up -d # The -d flag starts the containers in detached mode.
```

Access Logs and Terminal


``` sh
docker logs <container_id> # Replace <container_id> with your container's ID.
```

Stop the Application


``` sh
docker-compose down
```

Additional Notes

Quick facts

Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.

Sleeping Server for Minecraft is a free Minecraft Java mod. Compatible with Minecraft 1.7, 1.8, 1.9, 1.10 and newer. Downloaded 169 times (via Spigot). Download it and open it directly in the game.

Explore more