mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-03-02 12:56:25 +00:00
VanillaTweaks uses mc-image-helper and auto-cleans old files (#1581)
This commit is contained in:
@@ -78,7 +78,7 @@ In the cloned copy of [`mc-image-helper`](https://github.com/itzg/mc-image-helpe
|
|||||||
Assuming [http-server](https://www.npmjs.com/package/http-server) is installed globally, start a static web server using:
|
Assuming [http-server](https://www.npmjs.com/package/http-server) is installed globally, start a static web server using:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
http-server ./build/distributions -p 0
|
http-server ./build/distributions -p 8080
|
||||||
```
|
```
|
||||||
|
|
||||||
Note the port that was selected by http-server and pass the build arguments, such as:
|
Note the port that was selected by http-server and pass the build arguments, such as:
|
||||||
@@ -88,7 +88,7 @@ Note the port that was selected by http-server and pass the build arguments, suc
|
|||||||
--build-arg MC_HELPER_BASE_URL=http://host.docker.internal:8080
|
--build-arg MC_HELPER_BASE_URL=http://host.docker.internal:8080
|
||||||
```
|
```
|
||||||
|
|
||||||
Now the image can be built like normal and it will install mc-image-helper from the locally built copy.
|
Now the image can be built like normal, and it will install mc-image-helper from the locally built copy.
|
||||||
|
|
||||||
## Generating release notes
|
## Generating release notes
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ RUN easy-add --var os=${TARGETOS} --var arch=${TARGETARCH}${TARGETVARIANT} \
|
|||||||
--var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \
|
--var version=0.1.1 --var app=maven-metadata-release --file {{.app}} \
|
||||||
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
--from https://github.com/itzg/{{.app}}/releases/download/{{.version}}/{{.app}}_{{.version}}_{{.os}}_{{.arch}}.tar.gz
|
||||||
|
|
||||||
ARG MC_HELPER_VERSION=1.18.3
|
ARG MC_HELPER_VERSION=1.19.0
|
||||||
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION}
|
ARG MC_HELPER_BASE_URL=https://github.com/itzg/mc-image-helper/releases/download/v${MC_HELPER_VERSION}
|
||||||
RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \
|
RUN curl -fsSL ${MC_HELPER_BASE_URL}/mc-image-helper-${MC_HELPER_VERSION}.tgz \
|
||||||
| tar -C /usr/share -zxf - \
|
| tar -C /usr/share -zxf - \
|
||||||
|
|||||||
30
README.md
30
README.md
@@ -876,28 +876,30 @@ Datapacks will be placed in `/data/$LEVEL/datapacks`
|
|||||||
|
|
||||||
### VanillaTweaks
|
### VanillaTweaks
|
||||||
|
|
||||||
VanillaTweaks datapacks can be installed with a share code from the website UI **OR** a json file to specify packs to download and install.
|
[VanillaTweaks](https://vanillatweaks.net/) datapacks, crafting tweaks, and resource packs can be installed with a share code from the website **OR** a json file to specify packs to download and install. Datapacks and crafting tweaks will be installed into the current world directory specified by `$LEVEL`. As new versions of the packs are retrieved the previous versions will automatically be cleaned up.
|
||||||
|
|
||||||
Datapacks will be placed in `/data/$LEVEL/datapacks`
|
The share code is the part following the hash sign, as shown here:
|
||||||
Resourcepacks will be placed in `/data/resourcepacks`
|
|
||||||
|
```
|
||||||
|
https://vanillatweaks.net/share/#MGr52E
|
||||||
|
------
|
||||||
|
|
|
||||||
|
+- share code MGr52E
|
||||||
|
```
|
||||||
|
|
||||||
Accepted Parameters:
|
Accepted Parameters:
|
||||||
|
|
||||||
- `VANILLATWEAKS_FILE`
|
- `VANILLATWEAKS_FILE`: comma separated list of JSON VanillaTweak pack files accessible within the container
|
||||||
- `VANILLATWEAKS_SHARECODE`
|
- `VANILLATWEAKS_SHARECODE`: comma separated list of share codes
|
||||||
- `REMOVE_OLD_VANILLATWEAKS`
|
|
||||||
- `REMOVE_OLD_VANILLATWEAKS_DEPTH`
|
|
||||||
- `REMOVE_OLD_VANILLATWEAKS_INCLUDE`
|
|
||||||
- `REMOVE_OLD_VANILLATWEAKS_EXCLUDE`
|
|
||||||
|
|
||||||
Example of expected Vanillatweaks sharecode:
|
Example of expected VanillaTweaks share codes:
|
||||||
**Note**: ResourcePacks, DataPacks, and CraftingTweaks all have separate sharecodes
|
**Note**: ResourcePacks, DataPacks, and CraftingTweaks all have separate sharecodes
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
VANILLATWEAKS_SHARECODE: MGr52E,tF1zL2,LnEDwT
|
VANILLATWEAKS_SHARECODE: MGr52E,tF1zL2,LnEDwT
|
||||||
```
|
```
|
||||||
|
|
||||||
Example of expected Vanillatweaks file format:
|
Example of expected VanillaTweaks files:
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
VANILLATWEAKS_FILE: /config/vt-datapacks.json,/config/vt-craftingtweaks.json,/config/vt-resourcepacks.json
|
VANILLATWEAKS_FILE: /config/vt-datapacks.json,/config/vt-craftingtweaks.json,/config/vt-resourcepacks.json
|
||||||
@@ -925,8 +927,7 @@ Resourcepacks Json:
|
|||||||
"version": "1.18",
|
"version": "1.18",
|
||||||
"packs": {
|
"packs": {
|
||||||
"aesthetic": ["CherryPicking", "BlackNetherBricks", "AlternateBlockDestruction"]
|
"aesthetic": ["CherryPicking", "BlackNetherBricks", "AlternateBlockDestruction"]
|
||||||
},
|
}
|
||||||
"result": "ok"
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -941,8 +942,7 @@ CraftingTweaks Json:
|
|||||||
"double slabs",
|
"double slabs",
|
||||||
"back to blocks"
|
"back to blocks"
|
||||||
]
|
]
|
||||||
},
|
}
|
||||||
"result": "ok"
|
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -2,125 +2,18 @@
|
|||||||
|
|
||||||
set -e -o pipefail
|
set -e -o pipefail
|
||||||
|
|
||||||
: "${REMOVE_OLD_VANILLATWEAKS:=false}"
|
|
||||||
: "${VANILLATWEAKS_FILE:=}"
|
: "${VANILLATWEAKS_FILE:=}"
|
||||||
: "${VANILLATWEAKS_SHARECODE:=}"
|
: "${VANILLATWEAKS_SHARECODE:=}"
|
||||||
: "${REMOVE_OLD_VANILLATWEAKS_DEPTH:=1} "
|
|
||||||
: "${REMOVE_OLD_VANILLATWEAKS_INCLUDE:=*.zip}"
|
|
||||||
|
|
||||||
# shellcheck source=start-utils
|
# shellcheck source=start-utils
|
||||||
. "${SCRIPTS:-/}start-utils"
|
. "${SCRIPTS:-/}start-utils"
|
||||||
isDebugging && set -x
|
|
||||||
|
|
||||||
VT_VERSION=""
|
if [[ ${VANILLATWEAKS_FILE} || ${VANILLATWEAKS_SHARECODE} ]]; then
|
||||||
DATAPACKS_DIR="/data/${LEVEL:-world}/datapacks"
|
mc-image-helper vanillatweaks \
|
||||||
RESOURCEPACKS_DIR="/data/resourcepacks"
|
--output-directory="/data" \
|
||||||
|
--world-subdir="${LEVEL:-world}" \
|
||||||
# Remove old VANILLATWEAKS
|
--share-codes="$VANILLATWEAKS_SHARECODE" \
|
||||||
if isTrue "${REMOVE_OLD_VANILLATWEAKS}"; then
|
--pack-files="$VANILLATWEAKS_FILE"
|
||||||
# NOTE: datapacks include crafting tweaks.
|
|
||||||
if [ -d "$DATAPACKS_DIR" ]; then
|
|
||||||
find "$DATAPACKS_DIR" -mindepth 1 -maxdepth ${REMOVE_OLD_VANILLATWEAKS_DEPTH:-16} -wholename "${REMOVE_OLD_VANILLATWEAKS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_VANILLATWEAKS_EXCLUDE:-}" -delete
|
|
||||||
fi
|
|
||||||
if [ -d "$RESOURCEPACKS_DIR" ]; then
|
|
||||||
find "$RESOURCEPACKS_DIR" -mindepth 1 -maxdepth ${REMOVE_OLD_VANILLATWEAKS_DEPTH:-16} -wholename "${REMOVE_OLD_VANILLATWEAKS_INCLUDE:-*}" -not -wholename "${REMOVE_OLD_VANILLATWEAKS_EXCLUDE:-}" -delete
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Gets the download url and downloads the actual files.
|
|
||||||
getUrlAndDownload(){
|
|
||||||
VT_FILE=$1
|
|
||||||
URL_SUFFIX=$2
|
|
||||||
OUTPUT_FILE=$3
|
|
||||||
PACKS=$(jq -jc '.packs // empty' $VT_FILE)
|
|
||||||
if [ ! "$PACKS" ]; then
|
|
||||||
log "ERROR: unable to retrieve ${URL_SUFFIX} from ${VT_FILE}"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
ZIPDATA_URL="https://vanillatweaks.net/assets/server/zip${URL_SUFFIX}.php"
|
|
||||||
DOWNLOAD_URL=$(curl -X POST -F "packs=${PACKS}" -F "version=${VT_VERSION}" $ZIPDATA_URL | jq -r '.link // empty')
|
|
||||||
if [ ! "$DOWNLOAD_URL" ]; then
|
|
||||||
log "ERROR: unable to retrieve ${URL_SUFFIX} packs from vanillatweaks.net!"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! get -o $OUTPUT_FILE "https://vanillatweaks.net${DOWNLOAD_URL}"; then
|
|
||||||
log "ERROR: failed to download ${URL_SUFFIX} from ${DOWNLOAD_URL}"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Datapacks Handler
|
|
||||||
downloadDatapacks(){
|
|
||||||
VT_FILE=$1
|
|
||||||
URL_SUFFIX="datapacks"
|
|
||||||
OUTPUT_FILE="/tmp/vanillatweaks.zip"
|
|
||||||
getUrlAndDownload $VT_FILE $URL_SUFFIX $OUTPUT_FILE
|
|
||||||
mkdir -p "$DATAPACKS_DIR"
|
|
||||||
if ! unzip -o -d "$DATAPACKS_DIR" $OUTPUT_FILE; then
|
|
||||||
log "ERROR: failed to unzip the datapacks ${DATAPACKS} from ${OUTPUT_FILE}"
|
|
||||||
fi
|
|
||||||
rm -f $OUTPUT_FILE
|
|
||||||
}
|
|
||||||
|
|
||||||
# Crafting Tweaks Handler
|
|
||||||
downloadCraftingtweaks(){
|
|
||||||
VT_FILE=$1
|
|
||||||
mkdir -p "$DATAPACKS_DIR"
|
|
||||||
getUrlAndDownload $VT_FILE "craftingtweaks" "${DATAPACKS_DIR}/craftingtweaks.zip"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Resourcepacks Handler
|
|
||||||
downloadResourcepacks(){
|
|
||||||
VT_FILE=$1
|
|
||||||
mkdir -p "$RESOURCEPACKS_DIR"
|
|
||||||
getUrlAndDownload $VT_FILE "resourcepacks" "${RESOURCEPACKS_DIR}/resourcepacks.zip"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Example: VANILLATWEAKS_SHARECODE=MGr52E
|
|
||||||
# Code generated from the UI website, typically a alphanumeric 6 digit code.
|
|
||||||
if [[ "$VANILLATWEAKS_SHARECODE" ]]; then
|
|
||||||
VANILLATWEAKS_FILE=()
|
|
||||||
for SHARECODE in ${VANILLATWEAKS_SHARECODE//,/ }; do
|
|
||||||
TMP_FILE="/tmp/${SHARECODE}.json"
|
|
||||||
SHARECODE_LOOKUP_URL="https://vanillatweaks.net/assets/server/sharecode.php?code=${SHARECODE}"
|
|
||||||
if ! get -o "$TMP_FILE" "$SHARECODE_LOOKUP_URL"; then
|
|
||||||
log "ERROR: Unable to use ${SHARECODE} share code provided to retrieve vanillatweaks file"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
VANILLATWEAKS_FILE+="${TMP_FILE},"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Use vanillatweaks file to specify VT and datapacks and crafting tweaks
|
|
||||||
if [[ "$VANILLATWEAKS_FILE" ]]; then
|
|
||||||
for VT_FILE in ${VANILLATWEAKS_FILE//,/ }; do
|
|
||||||
if [ ! -f "$VT_FILE" ]; then
|
|
||||||
log "ERROR: given VANILLATWEAKS_FILE file does not exist"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
VT_VERSION=$(jq -jc '.version // empty' $VT_FILE)
|
|
||||||
if [ ! "$VT_VERSION" ]; then
|
|
||||||
log "ERROR: unable to retrieve version from $VT_FILE"
|
|
||||||
exit 2
|
|
||||||
fi
|
|
||||||
|
|
||||||
TYPE=$(jq -jc '.type // empty' $VT_FILE)
|
|
||||||
if [[ "$TYPE" = "datapacks" ]]; then
|
|
||||||
downloadDatapacks $VT_FILE
|
|
||||||
elif [[ "$TYPE" = "craftingtweaks" ]]; then
|
|
||||||
downloadCraftingtweaks $VT_FILE
|
|
||||||
elif [[ "$TYPE" = "resourcepacks" ]]; then
|
|
||||||
downloadResourcepacks $VT_FILE
|
|
||||||
fi
|
|
||||||
|
|
||||||
# cleans up temp vanilla tweaks file download to get stored packs
|
|
||||||
if [[ "$VANILLATWEAKS_SHARECODE" ]]; then
|
|
||||||
rm -f $VT_FILE
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec "${SCRIPTS:-/}start-setupDatapack" "$@"
|
exec "${SCRIPTS:-/}start-setupDatapack" "$@"
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
EULA: "TRUE"
|
EULA: "TRUE"
|
||||||
SETUP_ONLY: "TRUE"
|
SETUP_ONLY: "TRUE"
|
||||||
VERSION: ${MINECRAFT_VERSION:-LATEST}
|
CUSTOM_SERVER: /servers/fake.jar
|
||||||
VANILLATWEAKS_FILE: /config/vt-datapacks.json,/config/vt-craftingtweaks.json,/config/vt-resourcepacks.json
|
VANILLATWEAKS_FILE: /config/vt-datapacks.json,/config/vt-craftingtweaks.json,/config/vt-resourcepacks.json
|
||||||
REMOVE_OLD_VANILLATWEAKS: "FALSE"
|
REMOVE_OLD_VANILLATWEAKS: "FALSE"
|
||||||
volumes:
|
volumes:
|
||||||
@@ -15,3 +15,4 @@ services:
|
|||||||
- ./vt-datapacks.json:/config/vt-datapacks.json:ro
|
- ./vt-datapacks.json:/config/vt-datapacks.json:ro
|
||||||
- ./vt-craftingtweaks.json:/config/vt-craftingtweaks.json:ro
|
- ./vt-craftingtweaks.json:/config/vt-craftingtweaks.json:ro
|
||||||
- ./vt-resourcepacks.json:/config/vt-resourcepacks.json:ro
|
- ./vt-resourcepacks.json:/config/vt-resourcepacks.json:ro
|
||||||
|
- ./fake.jar:/servers/fake.jar
|
||||||
0
tests/setuponlytests/vanillatweaks_file/fake.jar
Normal file
0
tests/setuponlytests/vanillatweaks_file/fake.jar
Normal file
@@ -1,4 +1,4 @@
|
|||||||
mc-image-helper assert fileExists "/data/world/datapacks/afk*"
|
mc-image-helper assert fileExists "/data/world/datapacks/afk*"
|
||||||
mc-image-helper assert fileExists "/data/world/datapacks/graves*"
|
mc-image-helper assert fileExists "/data/world/datapacks/graves*"
|
||||||
mc-image-helper assert fileExists "/data/world/datapacks/craftingtweaks*"
|
mc-image-helper assert fileExists "/data/world/datapacks/VanillaTweaks_*"
|
||||||
mc-image-helper assert fileExists "/data/resourcepacks/resourcepacks*"
|
mc-image-helper assert fileExists "/data/resourcepacks/VanillaTweaks_*"
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
EULA: "TRUE"
|
EULA: "TRUE"
|
||||||
SETUP_ONLY: "TRUE"
|
SETUP_ONLY: "TRUE"
|
||||||
VERSION: ${MINECRAFT_VERSION:-LATEST}
|
CUSTOM_SERVER: /servers/fake.jar
|
||||||
VANILLATWEAKS_SHARECODE: MGr52E,tF1zL2,LnEDwT
|
VANILLATWEAKS_SHARECODE: MGr52E,tF1zL2,LnEDwT
|
||||||
REMOVE_OLD_VANILLATWEAKS: "FALSE"
|
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/data
|
- ./data:/data
|
||||||
|
- ./fake.jar:/servers/fake.jar
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
mc-image-helper assert fileExists "/data/world/datapacks/afk*"
|
mc-image-helper assert fileExists "/data/world/datapacks/afk*"
|
||||||
mc-image-helper assert fileExists "/data/world/datapacks/graves*"
|
mc-image-helper assert fileExists "/data/world/datapacks/graves*"
|
||||||
mc-image-helper assert fileExists "/data/world/datapacks/craftingtweaks*"
|
mc-image-helper assert fileExists "/data/world/datapacks/VanillaTweaks_488158f.zip"
|
||||||
mc-image-helper assert fileExists "/data/resourcepacks/resourcepacks*"
|
mc-image-helper assert fileExists "/data/resourcepacks/VanillaTweaks_d1d810f.zip"
|
||||||
|
|||||||
Reference in New Issue
Block a user