Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion minecraft-server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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=easy
10 changes: 10 additions & 0 deletions minecraft-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,16 @@ up:

## Server configuration

### Difficulty

The difficulty level (default: `easy`) can be set like:

docker run -d -e DIFFICULTY=hard

Valid values are: `peaceful`, `easy`, `normal`, and `hard`, and an
error message will be output in the logs if it's not one of these
values.

### Op/Administrator Players

To add more "op" (aka adminstrator) users to your Minecraft server, pass the Minecraft usernames separated by commas via the `OPS` environment variable, such as
Expand Down
22 changes: 22 additions & 0 deletions minecraft-server/start-minecraft.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 be 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)
Expand Down