mirror of
https://github.com/itzg/docker-minecraft-server
synced 2024-11-10 14:24:28 +00:00
Merge pull request #32 from timvisher/feature/add-difficulty-knob
Add difficulty knob.
This commit is contained in:
commit
83c31483f7
3 changed files with 33 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue