diff --git a/minecraft-server/Dockerfile b/minecraft-server/Dockerfile index 7af6626d..d57baa27 100644 --- a/minecraft-server/Dockerfile +++ b/minecraft-server/Dockerfile @@ -2,7 +2,7 @@ FROM itzg/ubuntu-openjdk-7 MAINTAINER itzg -ENV APT_GET_UPDATE 2015-03-28 +ENV APT_GET_UPDATE 2015-10-03 RUN apt-get update RUN DEBIAN_FRONTEND=noninteractive apt-get install -y libmozjs-24-bin imagemagick && apt-get clean @@ -31,4 +31,5 @@ ENV MC_IMAGE=YES ENV UID=1000 ENV MOTD A Minecraft Server Powered by Docker ENV JVM_OPTS -Xmx1024M -Xms1024M -ENV TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED LEVEL=world PVP=true DIFFICULTY=easy +ENV TYPE=VANILLA VERSION=LATEST FORGEVERSION=RECOMMENDED LEVEL=world PVP=true DIFFICULTY=easy \ + LEVEL_TYPE=DEFAULT GENERATOR_SETTINGS= diff --git a/minecraft-server/README.md b/minecraft-server/README.md index af04a4d3..b33459c4 100644 --- a/minecraft-server/README.md +++ b/minecraft-server/README.md @@ -183,11 +183,32 @@ message of the day that contains spaces by putting quotes around the whole thing ### PVP Mode -By default servers are created with player-vs-player (PVP) mode enabled. You can disable this with the `PVP` +By default, servers are created with player-vs-player (PVP) mode enabled. You can disable this with the `PVP` environment variable set to `false`, such as docker run -d -e PVP=false ... +### Level Type and Generator Settings + +By default, a standard world is generated with hills, valleys, water, etc. A different level type can +be configured by setting `LEVEL_TYPE` to + +* DEFAULT +* FLAT +* LARGEBIOMES +* AMPLIFIED +* CUSTOMIZED + +Descriptions are available at the [gamepedia](http://minecraft.gamepedia.com/Server.properties). + +When using a level type of `FLAT` and `CUSTOMIZED`, you can further configure the world generator +by passing [custom generator settings](http://minecraft.gamepedia.com/Superflat). +**Since generator settings usually have ;'s in them, surround the -e value with a single quote, like below.** + +For example (just the `-e` bits): + + -e LEVEL_TYPE=flat -e 'GENERATOR_SETTINGS=3;minecraft:bedrock,3*minecraft:stone,52*minecraft:sandstone;2;' + ### World Save Name You can either switch between world saves or run multiple containers with different saves by using the `LEVEL` option, diff --git a/minecraft-server/server.properties b/minecraft-server/server.properties index 0d7f77da..ddad1242 100644 --- a/minecraft-server/server.properties +++ b/minecraft-server/server.properties @@ -30,4 +30,4 @@ generate-structures=true view-distance=10 spawn-protection=16 motd=A Minecraft Server powered by Docker - +generator-settings= diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index 38a595ea..9dc50489 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -105,6 +105,25 @@ if [ ! -e server.properties ]; then sed -i "/pvp\s*=/ c pvp=$PVP" /data/server.properties fi + if [ -n "$LEVEL_TYPE" ]; then + # normalize to uppercase + LEVEL_TYPE=${LEVEL_TYPE^^} + # check for valid values and only then set + case $LEVEL_TYPE in + DEFAULT|FLAT|LARGEBIOMES|AMPLIFIED|CUSTOMIZED) + sed -i "/level-type\s*=/ c level-type=$LEVEL_TYPE" /data/server.properties + ;; + *) + echo "Invalid LEVEL_TYPE: $LEVEL_TYPE" + exit 1 + ;; + esac + fi + + if [ -n "$GENERATOR_SETTINGS" ]; then + sed -i "/generator-settings\s*=/ c generator-settings=$GENERATOR_SETTINGS" /data/server.properties + fi + if [ -n "$DIFFICULTY" ]; then case $DIFFICULTY in peaceful)