Add difficulty knob.

This commit is contained in:
Tim Visher 2015-06-10 14:13:36 -04:00
parent 6ba5fe29c1
commit b86370295c
2 changed files with 23 additions and 1 deletions

View file

@ -31,4 +31,4 @@ 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 LEVEL=world PVP=true
ENV TYPE=VANILLA VERSION=LATEST LEVEL=world PVP=true DIFFICULTY=hard

View file

@ -97,6 +97,28 @@ if [ ! -e server.properties ]; then
sed -i "/pvp\s*=/ c pvp=$PVP" /data/server.properties
fi
if [ -n "$DIFFICULTY" ]; then
case $DIFFICULTY in
peaceful)
DIFFICULTY=0
;;
easy)
DIFFICULTY=1
;;
normal)
DIFFICULTY=2
;;
hard)
DIFFICULTY=3
;;
*)
echo "DIFFICULTY must by peaceful, easy, normal, or hard."
exit 1
;;
esac
sed -i "/difficulty\s*=/ c difficulty=$DIFFICULTY" /data/server.properties
fi
if [ -n "$MODE" ]; then
case ${MODE,,?} in
0|1|2|3)