From ba08a5d8f1b2eaced2a227a52a06f77d6ae08619 Mon Sep 17 00:00:00 2001 From: chblodg Date: Fri, 4 Mar 2022 14:52:00 -0800 Subject: [PATCH] Fixing missing export, fixed run order, added real world working example (#1397) --- examples/docker-compose-rconcmd.yml | 12 +++++++++--- files/rconcmds/rcon-cmds-daemon.sh | 18 +++++++++++------- scripts/start-rconcmds | 1 + 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/examples/docker-compose-rconcmd.yml b/examples/docker-compose-rconcmd.yml index f09f8bce..ad8ff60a 100644 --- a/examples/docker-compose-rconcmd.yml +++ b/examples/docker-compose-rconcmd.yml @@ -9,22 +9,28 @@ services: - "mc:/data" environment: EULA: "TRUE" + TYPE: FABRIC + MODS_FORGEAPI_PROJECTIDS: 433175 + MODS_FORGEAPI_KEY: ${MODS_FORGEAPI_KEY} + MODS_FORGEAPI_DOWNLOAD_DEPENDENCIES: "TRUE" + REMOVE_OLD_FORGEAPI_MODS: "TRUE" # YAML Heredoc, be sure to use '|-' this will remove the first newline and final new line. # This is versus '|' that will leaving with two empty strings at top and bottom. RCON_CMDS_STARTUP: |- - /pregen start 200 /gamerule doFireTick false /team add New /team add Old + /chunky radius 1000 + /chunky start RCON_CMDS_ON_CONNECT: |- /team join New @a[team=] /give @a[team=New] birch_boat /team join Old @a[team=New] RCON_CMDS_FIRST_CONNECT: |- - /pregen stop + /chunky pause RCON_CMDS_LAST_DISCONNECT: |- /kill @e[type=minecraft:boat] - /pregen start 200 + /chunky continue restart: unless-stopped volumes: mc: {} diff --git a/files/rconcmds/rcon-cmds-daemon.sh b/files/rconcmds/rcon-cmds-daemon.sh index d9db30fa..9774c556 100644 --- a/files/rconcmds/rcon-cmds-daemon.sh +++ b/files/rconcmds/rcon-cmds-daemon.sh @@ -60,6 +60,15 @@ do ;; XII) CURR_CLIENTCONNECTIONS=$(java_clients_connections) + # First client connection + # Setting priority run order: on first client connection is usually to STOP maintence, aka DO THIS FIRST + if (( CURR_CLIENTCONNECTIONS > 0 )) && (( CLIENTCONNECTIONS == 0 )) && [[ "$RCON_CMDS_FIRST_CONNECT" ]]; then + logRcon "First Clients has Connected, running first connect cmds" + while read -r cmd; do + run_command "$cmd" + done <<< "$RCON_CMDS_FIRST_CONNECT" + fi + # When a client joins if (( CURR_CLIENTCONNECTIONS > CLIENTCONNECTIONS )) && [[ "$RCON_CMDS_ON_CONNECT" ]]; then logRcon "Clients have Connected, running connect cmds" @@ -74,14 +83,9 @@ do done <<< "$RCON_CMDS_ON_DISCONNECT" fi - # First client connection - if (( CURR_CLIENTCONNECTIONS > 0 )) && (( CLIENTCONNECTIONS == 0 )) && [[ "$RCON_CMDS_FIRST_CONNECT" ]]; then - logRcon "First Clients has Connected, running first connect cmds" - while read -r cmd; do - run_command "$cmd" - done <<< "$RCON_CMDS_FIRST_CONNECT" # Last client connection - elif (( CURR_CLIENTCONNECTIONS == 0 )) && (( CLIENTCONNECTIONS > 0 )) && [[ "$RCON_CMDS_LAST_DISCONNECT" ]]; then + # Setting priority run order: on last client connection is usually to START maintence, aka DO THIS LAST + if (( CURR_CLIENTCONNECTIONS == 0 )) && (( CLIENTCONNECTIONS > 0 )) && [[ "$RCON_CMDS_LAST_DISCONNECT" ]]; then logRcon "ALL Clients have Disconnected, running last disconnect cmds" while read -r cmd; do run_command "$cmd" diff --git a/scripts/start-rconcmds b/scripts/start-rconcmds index 28fbfeee..67d4be87 100644 --- a/scripts/start-rconcmds +++ b/scripts/start-rconcmds @@ -13,6 +13,7 @@ export RCON_CMDS_STARTUP export RCON_CMDS_ON_CONNECT export RCON_CMDS_ON_DISCONNECT +export RCON_CMDS_FIRST_CONNECT export RCON_CMDS_LAST_DISCONNECT export RCON_CMDS_PERIOD export SERVER_PORT