💤 Put your Minecraft server to rest when idle.

Overview

Build status on GitLab CI Project license

lazymc

lazymc puts your Minecraft server to rest when idle, and wakes it up when players connect.

Some Minecraft servers (especially modded) use an insane amount of resources when nobody is playing. lazymc helps by stopping your server when idle, until a player connects again.

lazymc functions as proxy between clients and the server. It handles all incoming status connections until the server is started and then transparently relays/proxies the rest. All without them noticing.

lazymc-demo.mp4
Click to see screenshots

Sleeping server Join sleeping server Starting server Started server

Features

  • Very efficient, lightweight & low-profile (~3KB RAM)
  • Supports Minecraft Java Edition 1.6+, supports modded (e.g. Forge, FTB)
  • Transparent join: hold clients when server starts, relay when ready, without them noticing
  • Customizable MOTD and login messages
  • Automatically manages server.properties (host, port and RCON settings)
  • Graceful server sleep/shutdown through RCON (with SIGTERM fallback on Linux/Unix)
  • Restart server on crash

Requirements

  • Linux, macOS or Windows
  • Minecraft Java Edition 1.6+
  • On Windows: RCON (automatically managed)

Note: You must have access to the system to run the lazymc binary. If you're using a Minecraft shared hosting provider with a custom dashboard, you likely won't be able to set this up.

Usage

Note: these instructions are for Linux & macOS, for Windows look here.

Make sure you meet all requirements.

Download the appropriate binary for your system from the latest release page.

Place the binary in your Minecraft server directory, rename it if you like. Open a terminal, go to the directory, and make sure you can invoke it:

chmod a+x ./lazymc
./lazymc --help

When lazymc is set-up, change into your server directory if you haven't already. Then set up the configuration and start it up:

# Change into your server directory (if you haven't already)
cd server

# Generate lazymc configuration
lazymc config generate

# Edit configuration
# Set the correct server address, directory and start command
nano lazymc.toml

# Start lazymc
lazymc start

Everything should now be running. Connect with your Minecraft client to wake your server up!

Note: If a binary for your system isn't provided, please compile from source.

Note: Installation options are limited at this moment. More will be added later.

Compile from source

Make sure you meet all requirements.

To compile from source you need Rust, install it through rustup: https://rustup.rs/

When Rust is installed, compile and install lazymc from this git repository directly:

# Compile and install lazymc from source
cargo install -f --git https://github.com/timvisee/lazymc

# Ensure lazymc works
lazymc --help

Or clone the repository and build it yourself:

# Clone repository
git clone https://github.com/timvisee/lazymc
cd lazymc

# Compile
cargo build --release

# Run lazymc
./target/release/lazymc --help

License

This project is released under the GNU GPL-3.0 license. Check out the LICENSE file for more information.

Comments
  • MOTD doesn't show up (1.17.1, macOS, ARM)

    MOTD doesn't show up (1.17.1, macOS, ARM)

    As stated in the title - Motd doesn't display on macOS. Everything else works like a charm. The server correctly wakes up on connection and goes asleep on idle.

    Screnshot:

    image

    Of course, I have the latest version lazymc-v0.2.2-macos.

    System specification
    Hardware overview:
    
       Model Name: Mac mini
       Model Identifier: Macmini9,1
       Chip: Apple M1
       Total number of cores: 8 (performance: 4, efficiency: 4)
       Memory: 8 GB
       System version hardware: 7429.41.5
       OS loader: 7429.41.5
       Serial number (system): C07F1A4ZQ6NV
       Hardware UUID: 352FB5D9-7603-5D67-AF8C-9624D5CBE190
       CERTIFICATION UDID: 00008103-001215100E8A001E
       Activation Lock Status: Enabled
    
    server.properties
    #Minecraft server properties
    #Sun Nov 21 23:42:56 CET 2021
    enable-jmx-monitoring=false
    rcon.port=25575
    enable-command-block=false
    gamemode=survival
    enable-query=false
    level-name=world
    motd=A Minecraft Server
    query.port=25566
    pvp=true
    difficulty=easy
    network-compression-threshold=256
    max-tick-time=60000
    require-resource-pack=false
    max-players=20
    use-native-transport=true
    online-mode=true
    enable-status=true
    allow-flight=false
    broadcast-rcon-to-ops=true
    view-distance=10
    server-ip=127.0.0.1
    resource-pack-prompt=
    allow-nether=true
    server-port=25566
    enable-rcon=true
    sync-chunk-writes=true
    op-permission-level=4
    prevent-proxy-connections=false
    resource-pack=
    entity-broadcast-range-percentage=100
    rcon.password=RoxyPoxy23
    player-idle-timeout=0
    debug=false
    force-gamemode=false
    rate-limit=0
    hardcore=false
    white-list=false
    broadcast-console-to-ops=true
    spawn-npcs=true
    spawn-animals=true
    snooper-enabled=true
    function-permission-level=2
    text-filtering-config=
    spawn-monsters=true
    enforce-whitelist=false
    resource-pack-sha1=
    spawn-protection=16
    max-world-size=29999984
    
    lazymc.toml
    # lazymc configuration
    #
    # You must configure your server directory and start command, see:
    # - server.directory
    # - server.command
    #
    # All defaults are commented out, change it if you desire.
    # You can probably leave the rest as-is.
    #
    # You may generate a new configuration with: lazymc config generate
    # Or find the latest at: https://is.gd/WWBIQu
    
    [public]
    # Public address. IP and port users connect to.
    # Shows sleeping status, starts server on connect, and proxies to server.
    address = "0.0.0.0:25565"
    
    # Server version & protocol hint.
    # Sent to clients until actual server version is known.
    # See: https://is.gd/FTQKTP
    version = "1.17.1"
    protocol = 756
    
    [server]
    # Server address. Internal IP and port of server started by lazymc to proxy to.
    # Port must be different from public port.
    address = "127.0.0.1:25566"
    
    # Server directory, defaults to current directory.
    directory = "."
    
    # Command to start the server.
    # Warning: if using a bash script read: https://is.gd/k8SQYv
    command = "java -server  -jar paper-1.17.1-388.jar nogui"
    
    # Immediately wake server when starting lazymc.
    #wake_on_start = false
    
    # Immediately wake server after crash.
    #wake_on_crash = false
    
    # Server start/stop timeout in seconds. Force kill server process if it takes too long.
    #start_timeout = 300
    #stop_timeout = 150
    
    # Block banned IPs as listed in banned-ips.json in server directory.
    block_banned_ips = true
    
    # Drop connections from banned IPs.
    # Banned IPs won't be able to ping or request server status.
    # On connect, clients show a 'Disconnected' message rather than the ban reason.
    #drop_banned_ips = false
    
    [time]
    # Sleep after number of seconds.
    sleep_after = 60
    
    # Minimum time in seconds to stay online when server is started.
    minimum_online_time = 60
    
    [motd]
    # MOTD, shown in server browser.
    sleeping = "☠ Server is sleeping\n§2☻ Join to start it up"
    starting = "§2☻ Server is starting...\n§7⌛ Please wait..."
    stopping = "☠ Server going to sleep...\n⌛ Please wait..."
    
    # Use MOTD from Minecraft server once known.
    from_server = false
    
    [join]
    # Methods to use to occupy a client on join while the server is starting.
    # Read about all methods and configure them below.
    # Methods are used in order, if none is set, the client disconnects without a message.
    methods = [
        "hold",
        "kick",
    ]
    
    [join.kick]
    # Kick occupation method.
    # Instantly kicks a client with a message.
    
    # Message shown when client is kicked while server is starting/stopping.
    starting = "Server is starting... §c♥§r\n\nThis may take some time.\n\nPlease try to reconnect in a minute."
    stopping = "Server is going to sleep... §7☠§r\n\nPlease try to reconnect in a minute to wake it again."
    
    [join.hold]
    # Hold occupation method.
    # Holds back a joining client while the server is started until it is ready.
    # 'Connecting the server...' is shown on the client while it's held back.
    # If the server starts fast enough, the client won't notice it was sleeping at all.
    # This works for a limited time of 30 seconds, after which the Minecraft client times out.
    
    # Hold client for number of seconds on connect while server starts.
    # Keep below Minecraft timeout of 30 seconds.
    timeout = 25
    
    [join.forward]
    # Forward occupation method.
    # Instantly forwards (proxies) the client to a different address.
    # You may need to configure target server for it, such as allowing proxies.
    # Consumes client, not allowing other join methods afterwards.
    
    # IP and port to forward to.
    # The target server will receive original client handshake and login request as received by lazymc.
    #address = "127.0.0.1:25565"
    
    [join.lobby]
    # Lobby occupation method.
    # The client joins a fake lobby server with an empty world, floating in space.
    # A message is overlayed on screen to notify the server is starting.
    # The client will be teleported to the real server once it is ready.
    # This may keep the client occupied forever if no timeout is set.
    # Consumes client, not allowing other join methods afterwards.
    
    # !!! WARNING !!!
    # This is highly experimental, incomplete and unstable.
    # This may break the game and crash clients.
    # Don't enable this unless you know what you're doing.
    #
    # - Only works with offline mode
    # - Only works with vanilla Minecraft clients, does not work with modded
    # - Only tested with Minecraft 1.17.1
    
    # Maximum time in seconds in the lobby while the server starts.
    #timeout = 600
    
    # Message banner in lobby shown to client.
    #message = "§2Server is starting\n§7⌛ Please wait..."
    
    # Sound effect to play when server is ready.
    #ready_sound = "block.note_block.chime"
    
    [lockout]
    # Enable to prevent everybody from connecting through lazymc. Instantly kicks player.
    #enabled = false
    
    # Kick players with following message.
    #message = "Server is closed §7☠§r\n\nPlease try to reconnect in a minute."
    
    [rcon]
    # Enable sleeping server through RCON.
    # Must be enabled on Windows.
    enabled = true
    
    # Server RCON port. Must differ from public and server port.
    port = 25575
    
    # Server RCON password.
    # Or whether to randomize password each start (recommended).
    password = "RoxyPoxy23"
    randomize_password = false
    
    [advanced]
    # Automatically update values in Minecraft server.properties file as required.
    rewrite_server_properties = true
    
    [config]
    # lazymc version this configuration is for.
    # Don't change unless you know what you're doing.
    version = "0.2.2"
    

    If it matters - I have already turned off the firewall in system preferences (I don't know if it makes sense of localhost environment, but I did it just to be sure).

    I have already tried to run it inside of a Docker container (following crbanman/papermc-lazymc-docker project), but using the binary built for linux-aarch64. Anyway, it ends with exactly the same results - MOTD doesn't work at all.

    I am pretty new to this whole world of containers, binaries, proxying etc. so sorry if I have left something important without proper explanation.

    bug 
    opened by IdkMan2 13
  • players with different IP are connected under the same IP

    players with different IP are connected under the same IP

    when i connected to my own server in console my ip was127.0.0.1, I thought this was normal because server and me is on the same network (but this never happened on another server before), but when my friend joined he also connected as 127.0.0.1, being in a completely different city and having a different IP image image its not very big issue at least for me, but i cant use all functions of my auth plugin, and cannot use ban-ip because of that

    question 
    opened by ventoryprod 8
  • Would this code/pattern be usable in a cloudflare worker?

    Would this code/pattern be usable in a cloudflare worker?

    Really cool project, only downside is in its current state I’d still have to pay for something always, I’m wondering if this pattern could be used in cloudflare workers or AWS lambdas so that you are only charged on invocations. (Granted I’m not super familiar with either of those technologies and their limitations)

    question 
    opened by garrettjoecox 5
  •  Failed to serve status: ()

    Failed to serve status: ()

    Not an issue just asking why this happens.

    Version: Forge 1.12.2 Plugins: None Platform: ubuntu 20.4

    the warn WARN lazymc > Failed to serve status: () appears when the server is IDLE

    thanks in advance <3

    opened by NereaCassian 4
  • Add some sort of

    Add some sort of "wake up" whitelist

    Hi, it would be nice if not everyone could start up the server. In my case I would have to start quite a big modpack server just to then tell the user that they are not allowed to join. This would keep resources free as long as "actual" users try to wake the server up. I could imagine an option like "use_server_whitelist" or "use_custom_whitelist" with manual entries (e.g. the server does not use a whitelist but waking up should be limited to certain users; don't know if this is sensible or not).

    Thank you very much.

    enhancement 
    opened by dschemp 4
  • Server start takes too long lazymc timesout

    Server start takes too long lazymc timesout

    Server start takes too long lazymc timesout, running direwolf20 and it has a lot of mods so server start takes awhile that lazymc times out and kills the server start.

    Anyway to fix this?

    ERROR lazymc::montior > Force killing server, took too long to start or stop WARN lazymc > Server process stopped with error code (signal: 9) ERROR lazymc::montior > Force killing server, took too long to start or stop WARN lazymc > Failed to force kill server INFO lazymc::monitor > Server is now sleeping

    question 
    opened by Nullvoid3771 3
  • Not gracefully shutting down server?

    Not gracefully shutting down server?

    I'm concerned about this, should I be? It seems as if lazymc is just force killing minecraft instead of issuing a stop command.

    INFO lazymc::monitor > Server is now online INFO lazymc::montior > Server has been idle, sleeping... WARN lazymc > Server process stopped with error code (exit status: 143) INFO lazymc::monitor > Server is now sleeping

    opened by Milkysunshine 3
  • sometimes server refuses to turn off

    sometimes server refuses to turn off

    Hi again, Recently, I have begun to notice that the server may stop shutting down, specifically this happened for the third time in a week. Снимок экрана 2021-12-02 в 19 26 12 Can this happen because of plugins, or is it a lazymc error?

    bug 
    opened by ventoryprod 3
  • Keep alive when using portal chunk loading?

    Keep alive when using portal chunk loading?

    I don't know, how much insight into the world state and events within the server lazyMC actually has, but I was thinking about chunk loaders recently. I am about to build redstone machines on my server, that could break upon uncontrolled unloading. So I will add portal chunk loaders to keep the area loaded.

    As of my current understanding this would not prevent the server from shutting down, if no one is connected. Currently I keep an afk player on via the minecraft console client, but if they get disconnected for any reason (or are no good option in the case) the server will still shut down.

    Is there any way (or could one be added) to build something in-game to keep the server running until the redstone is finished?

    question 
    opened by mmodrow 2
  • Windows Machine running 1.18.2 Fabric Server critical error

    Windows Machine running 1.18.2 Fabric Server critical error

    Hi! I have been having a non-stop issue with LazyMC controlling my 1.18.2 fabric server jar. The server refuses to start with this error, which only occurs upon using LazyMC. If I use any other script to start the server including running the Jar, the server will launch fine without error. My java 17 paths are all properly used, and even by typing the default script thru the lazymc.toml config, such as: command = "java -Xmx1G -Xms1G -jar fabric-server.jar --nogui" the error still persists.

    INFO lazymc > Rewritten server.properties file with updated values INFO lazymc > Proxying public ~~~~~~~:25565 to server ~~~~~~~~:25566 INFO lazymc > Starting server... Error: A JNI error has occurred, please check your installation and try again Exception in thread "main" java.lang.ExceptionInInitializerError at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder.getDefaultProvider(FileSystems.java:114) at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder$1.run(FileSystems.java:103) at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder$1.run(FileSystems.java:101) at java.base/java.security.AccessController.doPrivileged(AccessController.java:318) at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder.defaultFileSystem(FileSystems.java:101) at java.base/java.nio.file.FileSystems$DefaultFileSystemHolder.(FileSystems.java:94) at java.base/java.nio.file.FileSystems.getDefault(FileSystems.java:183) at java.base/java.io.File.toPath(File.java:2387) at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1264) at java.base/java.util.zip.ZipFile$CleanableResource.(ZipFile.java:709) at java.base/java.util.zip.ZipFile.(ZipFile.java:243) at java.base/java.util.zip.ZipFile.(ZipFile.java:172) at java.base/java.util.jar.JarFile.(JarFile.java:347) at java.base/java.util.jar.JarFile.(JarFile.java:318) at java.base/java.util.jar.JarFile.(JarFile.java:257) at java.base/sun.launcher.LauncherHelper.getMainClassFromJar(LauncherHelper.java:541) at java.base/sun.launcher.LauncherHelper.loadMainClass(LauncherHelper.java:767) at java.base/sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:675) Caused by: java.nio.file.InvalidPathException: Illegal character [?] in path at index 2: \?\C:\Users\Name\Documents\Server at java.base/sun.nio.fs.WindowsPathParser.nextSlash(WindowsPathParser.java:212) at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:111) at java.base/sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77) at java.base/sun.nio.fs.WindowsFileSystem.(WindowsFileSystem.java:51) at java.base/sun.nio.fs.WindowsFileSystemProvider.(WindowsFileSystemProvider.java:54) at java.base/sun.nio.fs.DefaultFileSystemProvider.(DefaultFileSystemProvider.java:34) ... 18 more WARN lazymc > Server process stopped with error code (exit code: 1)

    question 
    opened by JsephGriff 2
  • Add option to exit

    Add option to exit

    Hi, I was wondering if adding a "stop" command would be possible because I'm able to start lazymc but I haven't found a way yet to stop the executable without manually killing the process. If there already is a way to do this please let me know. Thank you! 🙂

    question 
    opened by megabyte6 2
  • Bump tokio from 1.19.2 to 1.20.3

    Bump tokio from 1.19.2 to 1.20.3

    Bumps tokio from 1.19.2 to 1.20.3.

    Release notes

    Sourced from tokio's releases.

    Tokio v1.20.2

    1.20.2 (September 27, 2022)

    This release removes the dependency on the once_cell crate to restore the MSRV of the 1.20.x LTS release. (#5048)

    #5048: tokio-rs/tokio#5048

    Tokio v1.20.1

    1.20.1 (July 25, 2022)

    Fixed

    • chore: fix version detection in build script (#4860)

    #4860: tokio-rs/tokio#4860

    Tokio v1.20.0

    1.20.0 (July 12, 2022)

    Added

    Changed

    • time: remove src/time/driver/wheel/stack.rs (#4766)
    • rt: clean up arguments passed to basic scheduler (#4767)
    • net: be more specific about winapi features (#4764)
    • tokio: use const initialized thread locals where possible (#4677)
    • task: various small improvements to LocalKey (#4795)

    Fixed

    Documented

    • fs: warn about performance pitfall (#4762)
    • chore: fix spelling (#4769)
    • sync: document spurious failures in oneshot (#4777)
    • sync: add warning for watch in non-Send futures (#4741)
    • chore: fix typo (#4798)

    Unstable

    • joinset: rename join_one to join_next (#4755)
    • rt: unhandled panic config for current thread rt (#4770)

    #4677: tokio-rs/tokio#4677 #4741: tokio-rs/tokio#4741 #4755: tokio-rs/tokio#4755 #4758: tokio-rs/tokio#4758 #4762: tokio-rs/tokio#4762

    ... (truncated)

    Commits
    • ba81945 chore: prepare Tokio 1.20.3 release
    • 763bdc9 ci: run WASI tasks using latest Rust
    • 9f98535 Merge remote-tracking branch 'origin/tokio-1.18.x' into fix-named-pipes-1.20
    • 9241c3e chore: prepare Tokio v1.18.4 release
    • 699573d net: fix named pipes server configuration builder
    • 3d95a46 chore: prepare Tokio v1.20.2 (#5055)
    • 2063d66 Merge 'tokio-1.18.3' into 'tokio-1.20.x' (#5054)
    • 5c76d07 chore: prepare Tokio v1.18.3 (#5051)
    • 05e6614 chore: don't use once_cell for 1.18.x LTS release (#5048)
    • c0746b6 chore: prepare Tokio v1.20.1 (#4861)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Doesn't work with viaversion

    Doesn't work with viaversion

    Maybe there should be an option to accept a connection from any version? Would also need to make the server seem like it works on any version to clients

    opened by obj-obj 0
  • Bash start up - help needed

    Bash start up - help needed

    I'm currently running a VaultHunter server for some friends and thought this would be a great addition to help minimise resource use but having issues with getting the start.sh startup file that's provided with VaultHunters working with Lazymc.

    The server is starting up fine(when the proxy is first launched) but when it comes time for shutdown it gets stuck and just says "Server has been idle, sleeping...".

    In the lazymc.toml I have:

    # Command to start the server.
    command = "bash start.sh"
    

    I've edited the "shart.sh" as per the examples provided for bash scripts but with no luck. Pretty sure its my lack of understanding of the overly complex "shart.sh" provided by Vaulthunters.

    #!/usr/bin/env bash
    
    # Start script generated by ServerPackCreator 3.11.1.
    # Depending on which modloader is set, different checks are run to ensure the server will start accordingly.
    # If the modloader checks and setup are passed, Minecraft and EULA checks are run.
    # If everything is in order, the server is started.
    
    if [[ "$(id -u)" == "0" ]]; then
      echo "Warning! Running with administrator-privileges is not recommended."
    fi
    
    MINECRAFT_VERSION="1.16.5"
    MODLOADER="Forge"
    MODLOADER_VERSION="36.2.23"
    ARGS="-Xms6G -Xmx8G"
    JAVA="java"
    FABRIC_INSTALLER_VERSION="0.11.0"
    QUILT_INSTALLER_VERSION="0.4.3"
    MINECRAFT_SERVER_URL="https://launcher.mojang.com/v1/objects/1b557e7b033b583cd9f66746b7a9ab1ec1673ced/server.jar"
    
    # Variables with do_not_manually_edit are set automatically during script execution,
    # so manually editing them will have no effect, as they will be overridden.
    MINECRAFT_SERVER_JAR_LOCATION="do_not_manually_edit"
    LAUNCHER_JAR_LOCATION="do_not_manually_edit"
    SERVER_RUN_COMMAND="do_not_manually_edit"
    
    crash() {
      echo "Exiting..."
      read -n 1 -s -r -p "Press any key to continue"
      exit 1
    }
    
    
    # $1 = Filename to check for
    # $2 = Filename to save download as
    # $3 = URL to download $2 from
    # true if the file was successfully downloaded, false if it already exists
    downloadIfNotExist() {
      if [[ ! -s "${1}" ]]; then
        echo "${1} could not be found." >&2
        echo "Downloading ${2}" >&2
        echo "from ${3}" >&2
        wget -q --progress=bar --show-progress -O "./${2}" "${3}"
        if [[ -s "${2}" ]]; then
          echo "Download complete." >&2
          echo "true"
        fi
      else
        echo "${1} present." >&2
        echo "false"
      fi
    }
    
    runJavaCommand() {
      "$JAVA" ${1}
    }
    
    # If modloader = Forge, run Forge-specific checks
    setup_forge() {
      echo ""
      echo "Running Forge checks and setup..."
    
      FORGE_INSTALLER_URL="https://files.minecraftforge.net/maven/net/minecraftforge/forge/${MINECRAFT_VERSION}-${MODLOADER_VERSION}/forge-${MINECRAFT_VERSION}-${MODLOADER_VERSION}-installer.jar"
    
      FORGE_JAR_LOCATION="do_not_manually_edit"
      IFS="." read -ra MINOR <<<"${MINECRAFT_VERSION}"
    
      if [[ ${MINOR[1]} -le 16 ]]; then
    
        FORGE_JAR_LOCATION="forge.jar"
        LAUNCHER_JAR_LOCATION="forge.jar"
        MINECRAFT_SERVER_JAR_LOCATION="minecraft_server.${MINECRAFT_VERSION}.jar"
        SERVER_RUN_COMMAND="-Dlog4j2.formatMsgNoLookups=true ${ARGS} -jar ${LAUNCHER_JAR_LOCATION} nogui"
    
      else
    
        FORGE_JAR_LOCATION="libraries/net/minecraftforge/forge/${MINECRAFT_VERSION}-${MODLOADER_VERSION}/forge-${MINECRAFT_VERSION}-${MODLOADER_VERSION}-server.jar"
        MINECRAFT_SERVER_JAR_LOCATION="libraries/net/minecraft/server/${MINECRAFT_VERSION}/server-${MINECRAFT_VERSION}.jar"
        SERVER_RUN_COMMAND="-Dlog4j2.formatMsgNoLookups=true @user_jvm_args.txt @libraries/net/minecraftforge/forge/${MINECRAFT_VERSION}-${MODLOADER_VERSION}/unix_args.txt nogui"
    
        if [[ ! -s "user_jvm_args.txt" ]]; then
    
          {
            echo "# Xmx and Xms set the maximum and minimum RAM usage, respectively."
            echo "# They can take any number, followed by an M or a G."
            echo "# M means Megabyte, G means Gigabyte."
            echo "# For example, to set the maximum to 3GB: -Xmx3G"
            echo "# To set the minimum to 2.5GB: -Xms2500M"
            echo "# A good default for a modded server is 4GB."
            echo "# Uncomment the next line to set it."
    	echo "# -Xms6G"
            echo "# -Xmx10G"
            echo "${ARGS}"
          } >>user_jvm_args.txt
    
        else
          echo "user_jvm_args.txt present..."
        fi
    
      fi
    
      if [[ $(downloadIfNotExist "${FORGE_JAR_LOCATION}" "forge-installer.jar" "${FORGE_INSTALLER_URL}") == "true" ]]; then
    
        echo "Forge Installer downloaded. Installing..."
        runJavaCommand "-jar forge-installer.jar --installServer"
    
        if [[ ${MINOR[1]} -gt 16 ]]; then
    
          rm -f run.bat
          rm -f run.sh
    
        else
    
          echo "Renaming forge-${MINECRAFT_VERSION}-${MODLOADER_VERSION}.jar to forge.jar"
          mv forge-"${MINECRAFT_VERSION}"-"${MODLOADER_VERSION}".jar forge.jar
    
        fi
    
        if [[ -s "${FORGE_JAR_LOCATION}" ]]; then
    
          rm -f forge-installer.jar
          rm -f forge-installer.jar.log
          echo "Installation complete. forge-installer.jar deleted."
    
        else
    
          rm -f forge-installer.jar
          echo "Something went wrong during the server installation. Please try again in a couple of minutes and check your internet connection."
          crash
    
        fi
    
      fi
      echo ""
    }
    
    # If modloader = Fabric, run Fabric-specific checks
    setup_fabric() {
      echo ""
      echo "Running Fabric checks and setup..."
    
      FABRIC_INSTALLER_URL="https://maven.fabricmc.net/net/fabricmc/fabric-installer/${FABRIC_INSTALLER_VERSION}/fabric-installer-${FABRIC_INSTALLER_VERSION}.jar"
      FABRIC_CHECK_URL="https://meta.fabricmc.net/v2/versions/loader/${MINECRAFT_VERSION}/${MODLOADER_VERSION}/server/json"
      FABRIC_AVAILABLE="$(wget --server-response --spider --quiet ${FABRIC_CHECK_URL} 2>&1 | awk 'NR==1{print $2}')"
      IMPROVED_FABRIC_LAUNCHER_URL="https://meta.fabricmc.net/v2/versions/loader/${MINECRAFT_VERSION}/${MODLOADER_VERSION}/${FABRIC_INSTALLER_VERSION}/server/jar"
      IMPROVED_FABRIC_LAUNCHER_AVAILABLE="$(wget --server-response --spider --quiet ${IMPROVED_FABRIC_LAUNCHER_URL} 2>&1 | awk 'NR==1{print $2}')"
    
      if [[ "$IMPROVED_FABRIC_LAUNCHER_AVAILABLE" == "200" ]]; then
    
        echo "Improved Fabric Server Launcher available..."
        echo "The improved launcher will be used to run this Fabric server."
        LAUNCHER_JAR_LOCATION="fabric-server-launcher.jar"
        downloadIfNotExist "fabric-server-launcher.jar" "fabric-server-launcher.jar" "${IMPROVED_FABRIC_LAUNCHER_URL}" >/dev/null
    
      elif [[ "${FABRIC_AVAILABLE}" != "200" ]]; then
    
        echo "Fabric is not available for Minecraft ${MINECRAFT_VERSION}, Fabric ${MODLOADER_VERSION}."
        crash
    
      elif [[ $(downloadIfNotExist "fabric-server-launch.jar" "fabric-installer.jar" "${FABRIC_INSTALLER_URL}") == "true" ]]; then
    
        echo "Installer downloaded..."
        LAUNCHER_JAR_LOCATION="fabric-server-launch.jar"
        MINECRAFT_SERVER_JAR_LOCATION="server.jar"
        runJavaCommand "-jar fabric-installer.jar server -mcversion ${MINECRAFT_VERSION} -loader ${MODLOADER_VERSION} -downloadMinecraft"
    
        if [[ -s "fabric-server-launch.jar" ]]; then
    
          rm -rf .fabric-installer
          rm -f fabric-installer.jar
          echo "Installation complete. fabric-installer.jar deleted."
    
        else
    
          rm -f fabric-installer.jar
          echo "fabric-server-launch.jar not found. Maybe the Fabric servers are having trouble."
          echo "Please try again in a couple of minutes and check your internet connection."
          crash
    
        fi
    
      else
    
        echo "fabric-server-launch.jar present. Moving on..."
        LAUNCHER_JAR_LOCATION="fabric-server-launcher.jar"
        MINECRAFT_SERVER_JAR_LOCATION="server.jar"
    
      fi
    
      SERVER_RUN_COMMAND="-Dlog4j2.formatMsgNoLookups=true ${ARGS} -jar ${LAUNCHER_JAR_LOCATION} nogui"
      echo ""
    }
    
    # If modloader = Quilt, run Quilt-specific checks
    setup_quilt() {
      echo ""
      echo "Running Quilt checks and setup..."
    
      QUILT_INSTALLER_URL="https://maven.quiltmc.org/repository/release/org/quiltmc/quilt-installer/${QUILT_INSTALLER_VERSION}/quilt-installer-${QUILT_INSTALLER_VERSION}.jar"
      QUILT_CHECK_URL="https://meta.fabricmc.net/v2/versions/intermediary/${MINECRAFT_VERSION}"
      QUILT_AVAILABLE="$(wget -qO- ${QUILT_CHECK_URL})"
    
      if [[ "${#QUILT_AVAILABLE}" -eq "2" ]]; then
    
        echo "Quilt is not available for Minecraft ${MINECRAFT_VERSION}, Quilt ${MODLOADER_VERSION}."
        crash
    
      elif [[ $(downloadIfNotExist "quilt-server-launch.jar" "quilt-installer.jar" "${QUILT_INSTALLER_URL}") == "true" ]]; then
    
        echo "Installer downloaded. Installing..."
        runJavaCommand "-jar quilt-installer.jar install server ${MINECRAFT_VERSION} --download-server --install-dir=."
    
        if [[ -s "quilt-server-launch.jar" ]]; then
    
          rm quilt-installer.jar
          echo "Installation complete. quilt-installer.jar deleted."
    
        else
    
          rm -f quilt-installer.jar
          echo "quilt-server-launch.jar not found. Maybe the Quilt servers are having trouble."
          echo "Please try again in a couple of minutes and check your internet connection."
          crash
    
        fi
    
      else
        echo "quilt-server-launch.jar present. Moving on..."
      fi
    
      LAUNCHER_JAR_LOCATION="quilt-server-launch.jar"
      MINECRAFT_SERVER_JAR_LOCATION="server.jar"
      SERVER_RUN_COMMAND="-Dlog4j2.formatMsgNoLookups=true ${ARGS} -jar ${LAUNCHER_JAR_LOCATION} nogui"
      echo ""
    }
    
    # Check for a minecraft server and download it if necessary
    minecraft() {
      echo ""
      if [[ "${MODLOADER}" == "Fabric" && "$IMPROVED_FABRIC_LAUNCHER_AVAILABLE" == "200" ]]; then
    
        echo "Skipping Minecraft Server JAR checks because we are using the improved Fabric Server Launcher."
    
      else
    
        downloadIfNotExist "${MINECRAFT_SERVER_JAR_LOCATION}" "${MINECRAFT_SERVER_JAR_LOCATION}" "${MINECRAFT_SERVER_URL}" >/dev/null
    
      fi
      echo ""
    }
    
    # Check for eula.txt and generate if necessary
    eula() {
      echo ""
      if [[ ! -s "eula.txt" ]]; then
    
        echo "Mojang's EULA has not yet been accepted. In order to run a Minecraft server, you must accept Mojang's EULA."
        echo "Mojang's EULA is available to read at https://aka.ms/MinecraftEULA"
        echo "If you agree to Mojang's EULA then type 'I agree'"
        echo -n "Response: "
        read -r ANSWER
    
        if [[ "${ANSWER}" == "I agree" ]]; then
    
          echo "User agreed to Mojang's EULA."
          echo "#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://aka.ms/MinecraftEULA)." >eula.txt
          echo "eula=true" >>eula.txt
    
        else
    
          echo "User did not agree to Mojang's EULA."
          echo "Entered: ${ANSWER}"
          crash
    
        fi
    
      else
        echo "eula.txt present. Moving on..."
      fi
      echo ""
    }
    
    # Main
    if [[ "${MODLOADER}" == "Forge" ]]; then
    
      setup_forge
    
    elif [[ "${MODLOADER}" == "Fabric" ]]; then
    
      setup_fabric
    
    elif [[ "${MODLOADER}" == "Quilt" ]]; then
    
      setup_quilt
    
    else
    
      echo "Incorrect modloader specified."
      crash
    
    fi
    
    if [[ "${PWD}" == *" "*  ]]; then
    
        echo "WARNING! The current location of this script contains spaces. This may cause this server to crash!"
        echo "It is strongly recommended to move this server pack to a location whose path does NOT contain SPACES!"
        echo ""
        echo "Current path:"
        echo "${PWD}t"
        echo ""
    
        echo -n "Are you sure you want to continue? (Yes/No): "
        read -r ITIS2022WHYARESPACESSTILLSUCHAPROBLEMWHATTHEFRAG
    
        if [[ "${ITIS2022WHYARESPACESSTILLSUCHAPROBLEMWHATTHEFRAG}" == "Yes" ]]; then
    
            echo "Alrighty. Prepare for unforseen consequences, Mr. Freeman..."
    
        else
            crash
        fi
    fi
    
    minecraft
    eula
    
    echo ""
    echo "Starting server..."
    echo ""
    echo "Minecraft version: ${MINECRAFT_VERSION}"
    echo "Modloader:         ${MODLOADER}"
    echo "Modloader version: ${MODLOADER_VERSION}"
    if [[ ${LAUNCHER_JAR_LOCATION} != "do_not_manually_edit" ]]; then
      echo "Launcher JAR:      ${LAUNCHER_JAR_LOCATION}"
    fi
    echo ""
    echo "Java args:         ${ARGS}"
    echo "Java path:         ${JAVA}"
    echo "Run Command:       ${JAVA} ${SERVER_RUN_COMMAND}"
    echo "Java version:"
    "${JAVA}" -version
    echo ""
    
    # for lazymc
    trap 'kill -TERM $PID' TERM INT
    
    runJavaCommand "${SERVER_RUN_COMMAND}" &
    
    # for lazymc
    PID=$!
    wait $PID
    trap - TERM INT
    wait $PID
    
    echo ""
    echo "Exiting..."
    exit 0
    
    opened by LukeG20 0
  • Update lazymc to support 1.19(.2)

    Update lazymc to support 1.19(.2)

    I'm using the docker container. My server is on 1.19.2, and I thought changing the MC_VERSION env var and version and protocol in lazymc.toml would make it work. When the container starts, it tries to download a lazymc release with no version, so I'm guessing there's some changes to be made here.

    Edit: logs from the container

    --2022-10-10 00:20:21--  https://github.com/timvisee/lazymc/releases/download//lazymc--linux-x64
    
    Resolving github.com (github.com)... 140.82.121.4
    
    Connecting to github.com (github.com)|140.82.121.4|:443... connected.
    
    HTTP request sent, awaiting response... 404 Not Found
    
    2022-10-10 00:20:21 ERROR 404: Not Found.
    
    opened by jlxip 1
  • Magma Incompatibility

    Magma Incompatibility

    I tried everything reccomended by their wiki like enabling support for bungee i modified lazymc config as much as possible but nothing would work any solutions?

    opened by Yolomic 2
Releases(v0.2.7)
Owner
Tim Visée
On GitLab: https://gitlab.com/timvisee
Tim Visée
ULE - Minecraft's server core written in Rust

ULE - Minecraft's server core written in Rust This's server core fully written in Rust-Lang and using more custom code for best perfomance and control

null 13 Oct 26, 2022
This is a Minecraft Classic server written in Rust powered by tokio and classicl.

classicl_server Introduction This is a Minecraft Classic server written in Rust powered by tokio and classicl. Installation Cargo The project can be i

null 3 Nov 3, 2022
A programming language designed for the DiamondFire Minecraft server.

Blackstone Blackstone is a programming language designed to help create plots on the MCDiamondFire Minecraft server. Community Links Discord: https://

Blackstone 5 May 1, 2023
Rust implementation of the Minecraft authentication server (Yggdrasil)

yggoxide This crate currently implements the REST API for: Service Exposed at Minecraft Production Coverage Yggdrasil authentication / and /authserver

Mojank Studios 16 Jun 26, 2023
A reimplementation of the minecraft server framework in rust.

FerrumC About FerrumC is a Rust-based reimplementation of the Minecraft server, designed to be fast and efficient, optimized for low memory usage and

Sweattypalms 3 Sep 4, 2023
Easily update your minecraft mods with 1 file (guess I'm back to rust again)

Mod Updater This program updates all your mods to a newer/later version. To use: Create a file named config.toml Create a folder named mods; Add the f

sussyimpostor 2 Sep 18, 2022
Rust-based replacement for the default Minecraft renderer

wgpu-mc ?? A blazing fast alternative renderer for Minecraft Intro WebGPU is a new web specification designed to provide modern graphics and compute c

Birb 1 Jun 28, 2022
Rustcraft is a simple Minecraft engine written in rust using wgpu.

Rustcraft is a simple Minecraft engine written in rust using wgpu.

Raphael Van Hoffelen 110 Dec 22, 2022
A Minecraft Java Edition to Bedrock Edition resource pack convertor in Rust

j2be A Minecraft Java Edition to Bedrock Edition resource pack convertor in Rust How to use Note: This project is still in development Run cargo build

Cqdet 11 Sep 15, 2021
Minecraft Protocol Library

Protocol Minecraft Protocol Library This branch is dedicated to the Minecraft Bedrock Edition Protocol. If you have any concerns or questions you can

Netrex 5 Mar 19, 2022
Bell is a work in progress programming language that compiles to MCfunction (Minecraft's language for creating datapacks).

Bell is a work in progress programming language that compiles to MCfunction (Minecraft's language for creating datapacks). It provides a higher level,

Yoav 17 Aug 25, 2022
Minecraft-esque voxel engine prototype made with the bevy game engine. Pending bevy 0.6 release to undergo a full rewrite.

vx_bevy A voxel engine prototype made using the Bevy game engine. Goals and features Very basic worldgen Animated chunk loading (ala cube world) Optim

Lucas Arriesse 125 Dec 31, 2022
Provision Mammoth-ready Minecraft clusters with ease!

Minecraft Server Provisioner Provision Mammoth-ready Minecraft clusters with ease! Overview Provisioner is a tool designed to make the creation of Mam

null 19 Sep 29, 2022
A simple Minecraft written in Rust with the Piston game engine

hematite A simple Minecraft written in Rust with the Piston game engine How To Open a World This method is only for personal use. Never distribute cop

PistonDevelopers 1.7k Dec 22, 2022
Like minecraft, but crispier!

crispycraft Like minecraft, but crispier! Links Library documentation WebGPU: https://docs.rs/wgpu/0.12.0/wgpu/ building_blocks: https://docs.rs/build

null 1 Jan 15, 2022
Brine is my attempt at writing a Minecraft client in Rust using the Bevy game engine.

Brine Brine is my attempt at writing a Minecraft client in Rust using the Bevy game engine. It's EXTREMELY work-in-progress. The thing that makes Brin

Ben Reeves 34 Dec 26, 2022
Morphosis is a work-in-progress set of tools to deal with Minecraft metadata, mainly for use with PolyMC.

Morphosis Morphosis is a work-in-progress set of tools to deal with Minecraft metadata, mainly for use with PolyMC. It consists of a library (metamorp

cozyGalvinism 3 May 3, 2022
A Rust library for reading asset files and resource packs for any version of Minecraft

minecraft-assets A Rust library for reading asset files and resource packs for any version of Minecraft. Example use minecraft_assets::api::AssetPack;

Ben Reeves 7 Aug 14, 2022
Libium is the backend of Ferium. It helps manage Minecraft mods from Modrinth, CurseForge, and Github Releases

Libium Libium is the backend of Ferium. It helps manage Minecraft mods from Modrinth, CurseForge, and Github Releases There are 3 main components in L

Ilesh Thiada 14 Dec 13, 2022