SleepingServerStarter

repository·master·Indexed 43 days ago

https://github.com/vincss/mcsleepingserverstarter

A utility for Minecraft servers that saves power and resources by keeping the server offline until a player attempts to connect. It features a Web GUI for remote management, port sharing for Bedrock Edition, and Discord webhook notifications. Supports Minecraft Java (up to 1.20.2, partial 1.21.3) and Bedrock (1.21.40). Version 1.11.4.

Tokens
7K
Snippets
18
Records
29
Agent score
56%

What's inside SleepingServerStarter

  1. Overview of SleepingServerStarter features and compatibility

    master

    SleepingServerStarter is a tool designed to save power by automatically launching your Minecraft server when someone attempts to connect, and shutting it down when idle.

    Key Features

    • Port Sharing: Listens on the same port as your Minecraft server. This allows Bedrock Edition players to connect.
    • Web GUI: Includes a web interface to remotely turn your server on or off.
    • Auto-Launch: Automatically starts the Minecraft server upon connection attempts. You can also trigger a start by typing quit in the console.
    • Optimization: Works best when paired with tools that automatically stop the server after a period of inactivity, such as EmptyServerStopper or the NoPlayerShutdown mod.

    Compatibility

    • Minecraft Java: Supports up to version 1.20.2 (with partial support for 1.21.3) via node-minecraft-protocol.
    • Minecraft Bedrock: Supports version 1.21.40 via JSPrismarine.
  2. Install SleepingServerStarter via Binaries

    master

    The easiest way to install SleepingServerStarter is by using pre-compiled binaries.

    1. Download the binary corresponding to your operating system from the releases page.
    2. Place the executable in the same working directory as your Minecraft server files (e.g., next to spigot.jar or paper.jar).
    3. Ensure your Minecraft server is currently stopped.
    4. Run the executable.

    Note for Linux users: If you cannot run the executable, you may need to grant it execution permissions using chmod +x <filename>.

    chmod +x mcsleepingserverstarter-linux-x64
  3. Install SleepingServerStarter manually via Node.js

    master

    If you prefer to compile from source, you can install SleepingServerStarter manually using Node.js.

    Prerequisites:

    Steps:

    1. Clone the repository or download the project as a ZIP file.
    2. Unzip or clone the project into the same folder as your Minecraft server.
    3. Run npm ci to install dependencies.
    4. Start the project using npm start.
    npm ci
    npm start
  4. Integrate SleepingServerStarter with a Bungeecord network

    master

    SleepingServerStarter can be used within a Bungeecord network to manage multiple servers. However, it must be installed and configured on every individual server you want the program to manage. Installing it only on the Bungeecord proxy will not work.

    When a player attempts to join a server that is currently sleeping, Bungeecord will repeatedly kick them using the configured loginMessage as the reason, informing them that the server is being started. This provides a seamless user experience where players are notified of the startup process rather than seeing a generic connection error.

    ### Configuration Requirements for Bungeecord Integration
    
    For each server where SleepingServerStarter is installed:
    - Set `serverPort` to the port of the specific Minecraft server (not the Bungeecord proxy port).
    - Set `serverOnlineMode` to `false` to prevent connection issues when Bungee switches between servers.
  5. Configure SleepingServerStarter for Java Edition

    master

    To configure a Java Edition server, edit the sleepingSettings.yml file. If you are running from binaries, this file is automatically created in the same folder as the executable after the first execution.

    Key configuration areas include:

    • Server Identity: Set serverName and serverMOTD (supports color codes using the § prefix).
    • Networking: Define serverPort (set to 0 to disable) and webPort for the Web-GUI.
    • Minecraft Execution: Define the minecraftCommand (e.g., java -jar paper.jar --nogui) and the minecraftWorkingDirectory.
    • Access Control: Use whiteListedNames or useWhitelistFile (to use Minecraft's whitelist.json) to control who can wake the server.
    # Example sleepingSettings.yml snippet
    serverName: "§aMy Awesome Server"
    serverMOTD: "§bCome and play!"
    serverPort: 25565
    minecraftCommand: "java -jar paper.jar --nogui"
    whiteListedNames: ["player1", "player2"]
  6. Sync settings with server.properties

    master

    By setting useNativeFiles: true in your sleepingSettings.yml, the application will attempt to read and synchronize specific properties from your Minecraft server.properties file.

    Supported properties for synchronization:

    • query.port maps to serverPort
    • max-players maps to maxPlayers
    • online-mode maps to serverOnlineMode
    • white-list maps to useWhitelistFile

    Note: Enabling useNativeFiles automatically sets useBlacklistFiles to true.

  7. Configure JSPrismarine for Bedrock Edition

    master

    To configure a Bedrock Edition server, edit the config.yaml file.

    Note that sleepingSettings.yml is used for Java Edition, but for Bedrock, you must use config.yaml for all settings except bedrockPort, which remains in sleepingSettings.yml.

  8. Configure Discord Webhooks

    master

    You can integrate Discord notifications by configuring the discordWebhook object in your settings file. This allows the server to send updates to your channel.

    Required/Available keys:

    • discordWebhook.url: Your Discord WebHook URL.
    • discordWebhook.name: The name displayed for the bot.
    • discordWebhook.avatar: The URL for the bot's avatar image.
    discordWebhook:
      url: "https://discord.com/api/webhooks/..."
      name: "My Server Bot"
      avatar: "https://example.com/avatar.png"
  9. Configure SleepingServerStarter settings

    master

    The project uses a YAML configuration file named sleepingSettings.yml to manage server behavior. If the file does not exist, the system will generate one using DefaultSettings.

    Key configuration options include:

    • serverName: The name displayed by the server.
    • serverPort: The TCP port for the server (default: 25565).
    • maxPlayers: Maximum player capacity.
    • loginMessage: The message shown to players when they connect.
    • serverOnlineMode: Boolean to toggle online mode (default: false).
    • startMinecraft: Whether to automatically start the Minecraft process (default: true).
    • minecraftCommand: The command used to launch the Minecraft server (e.g., java -jar paper.jar --nogui).
    • restartDelay: Delay in milliseconds before restarting the server (default: 5000).
    • useWhitelistFile: Enables loading player names from whitelist.json.
    • useBlacklistFiles: Enables loading banned IPs and players from JSON files.
    • useNativeFiles: If true, the system attempts to sync settings from the Minecraft server.properties file.
    serverName: "My Custom Sleeping Server"
    serverPort: 25565
    maxPlayers: 50
    loginMessage: "Server is waking up..."
    startMinecraft: true
    minecraftCommand: "java -jar paper.jar --nogui"
    restartDelay: 5000
    useWhitelistFile: true
    useBlacklistFiles: true
    useNativeFiles: false