Skip to content

Commit

Permalink
Use custom server icon, MOTD and gamemode (#293)
Browse files Browse the repository at this point in the history
* Remove (broken) Travis CI badge from README

* Use our great custom server-icon.png

from https://github.com/OASIS-learn-study/swissarmyknife-minecraft-server/blob/master/src/server-icon.png
from #74

* Use custom MOTD

* Use creative peaceful server.properties

Based on https://github.com/OASIS-learn-study/s2i-minecraft-server/blob/master/src/server.properties,
I've verified each of the properties we had there, but most of them were the defaults anyway, this is better.

* Using 0/1 instead of peaceful/creative doesn't work either...

... because of itzg/docker-minecraft-server#1452.

* Use custom server.properties instead of MODE & DIFFICULTY environment variables

because of itzg/docker-minecraft-server#1452

* Make GuardGameModeJoinListener log game mode changes

* Fix quite confusing 2nd bug in GuardGameModeJoinListener
  • Loading branch information
vorburger authored Apr 2, 2022
1 parent 3587643 commit 1e3526c
Show file tree
Hide file tree
Showing 8 changed files with 80 additions and 8 deletions.
7 changes: 6 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ RUN ./gradlew build -x test
# Keep any changes made here strictly in sync with Dockerfile-local
FROM itzg/minecraft-server:java8
COPY --from=build /project/web/build/libs/*-all.jar /mods/
COPY minecraft-server/* /data-init/

ENV EULA=TRUE
ENV TYPE=SPONGEVANILLA
ENV SKIP_SERVER_PROPERTIES=true
EXPOSE 25565 25575 7070 8080
ENTRYPOINT [ "/start" ]
ENTRYPOINT [ "/data-init/start-custom" ]

# TODO When https://github.com/itzg/docker-minecraft-server/issues/1449,
# then "ENV ICON=/data-init/server-icon.png", but until then that's in the start-custom
7 changes: 6 additions & 1 deletion Dockerfile-local
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@
# Keep any changes made here strictly in sync with Dockerfile
FROM itzg/minecraft-server:java8
COPY web/build/libs/*-all.jar /mods/
COPY minecraft-server/* /data-init/

ENV EULA=TRUE
ENV TYPE=SPONGEVANILLA
ENV SKIP_SERVER_PROPERTIES=true
EXPOSE 25565 25575 7070 8080
ENTRYPOINT [ "/start" ]
ENTRYPOINT [ "/data-init/start-custom" ]

# TODO When https://github.com/itzg/docker-minecraft-server/issues/1449,
# then "ENV ICON=/data-init/server-icon.png", but until then that's in the start-custom
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# <a href="https://www.learn.study"><img src="logo/oasis.learn.study-Minecraft-Scratch-HighRes.png" width="100"/></a> minecraft-storeys-maker [![Build Status](https://travis-ci.com/OASIS-learn-study/minecraft-storeys-maker.svg?branch=master)](https://travis-ci.com/OASIS-learn-study/minecraft-storeys-maker)
# <a href="https://www.learn.study"><img src="logo/oasis.learn.study-Minecraft-Scratch-HighRes.png" width="100"/></a> minecraft-storeys-maker

Minecraft extension to make your own stories in, with and for Minecraft - it's like being a movie director!

Expand Down
3 changes: 3 additions & 0 deletions minecraft-server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This directory contains configuration files for the Minecraft server, used by the `Dockerfile`.

The storeys server's plugin code is not here, but in `../web`.
Binary file added minecraft-server/server-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
49 changes: 49 additions & 0 deletions minecraft-server/server.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
spawn-protection=0
max-tick-time=60000
query.port=25565
generator-settings=
sync-chunk-writes=true
force-gamemode=false
allow-nether=true
enforce-whitelist=false
gamemode=1
broadcast-console-to-ops=true
enable-query=false
player-idle-timeout=0
difficulty=0
spawn-monsters=false
broadcast-rcon-to-ops=true
op-permission-level=4
pvp=true
entity-broadcast-range-percentage=100
snooper-enabled=true
level-type=DEFAULT
hardcore=false
enable-status=true
enable-command-block=true
max-players=20
network-compression-threshold=256
resource-pack-sha1=
max-world-size=29999984
function-permission-level=2
rcon.port=25575
server-port=25565
texture-pack=
server-ip=
spawn-npcs=true
allow-flight=false
level-name=world
view-distance=10
resource-pack=
spawn-animals=true
white-list=false
rcon.password=minecraft
generate-structures=true
max-build-height=256
online-mode=true
level-seed=
prevent-proxy-connections=false
use-native-transport=true
enable-jmx-monitoring=false
enable-rcon=true
motd=\u00A7a\u00A7l/make\u00A7r your \u00A7bown\u00A7r Plugins/Mods, \u00A7l\u00A76with Scratch\!
7 changes: 7 additions & 0 deletions minecraft-server/start-custom
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
set -euox pipefail

cp /data-init/server.properties /data/
cp /data-init/server-icon.png /data/

/start
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package ch.vorburger.minecraft.storeys.guard;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.spongepowered.api.data.key.Keys;
import org.spongepowered.api.entity.living.player.Player;
import org.spongepowered.api.entity.living.player.gamemode.GameMode;
Expand All @@ -32,22 +34,23 @@
*/
public class GuardGameModeJoinListener implements EventListener<Join> {

@Override
public void handle(Join joinEvent) throws Exception {
private static final Logger LOG = LoggerFactory.getLogger(GuardGameModeJoinListener.class);

@Override public void handle(Join joinEvent) throws Exception {
GameMode newGameMode = null;
Player player = joinEvent.getTargetEntity();
// NB: Order and use of if and not else if - because higher permission overrides lower...
// But beware that OPS on servers without permissions plugin (such as LuckPerms) have all permissions;
// therefore the last permission must be the one which we wants an OPS to have!
if (player.hasPermission("storeys.guard.adventure")) {
newGameMode = GameModes.ADVENTURE;
}
if (player.hasPermission("storeys.guard.creative")) {
newGameMode = GameModes.CREATIVE;
}
if (player.hasPermission("storeys.guard.survival")) {
newGameMode = GameModes.SURVIVAL;
}
if (newGameMode != null) {
player.offer(Keys.GAME_MODE, newGameMode);
LOG.info("Setting Player {} game mode to {} due to their storeys.guard.* permissions", player.getName(), newGameMode);
}
}

Expand Down

0 comments on commit 1e3526c

Please sign in to comment.