2017-11-01 05:42:44 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2021-11-13 03:17:21 +00:00
|
|
|
# shellcheck source=start-utils
|
|
|
|
. "${SCRIPTS:-/}start-utils"
|
2020-06-07 01:41:09 +00:00
|
|
|
set -e
|
|
|
|
isDebugging && set -x
|
2020-03-06 15:52:17 +00:00
|
|
|
|
2022-01-24 04:19:25 +00:00
|
|
|
if [ "$TYPE" = "CURSEFORGE" ]; then
|
2021-11-13 03:17:21 +00:00
|
|
|
worldDest=$FTB_DIR/${LEVEL:-world}
|
2019-01-09 00:28:34 +00:00
|
|
|
else
|
2021-11-13 03:17:21 +00:00
|
|
|
worldDest=/data/${LEVEL:-world}
|
2019-01-09 00:28:34 +00:00
|
|
|
fi
|
2018-09-12 01:38:54 +00:00
|
|
|
|
2020-07-11 18:09:48 +00:00
|
|
|
if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] ); then
|
2021-03-30 02:14:21 +00:00
|
|
|
if isTrue "${FORCE_WORLD_COPY}"; then
|
|
|
|
log "Removing existing world data in $worldDest ${worldDest}_nether ${worldDest}_the_end"
|
|
|
|
rm -rf "$worldDest" \
|
|
|
|
"${worldDest}_nether" \
|
|
|
|
"${worldDest}_the_end"
|
|
|
|
fi
|
|
|
|
|
2022-01-24 04:19:25 +00:00
|
|
|
if isURL "$WORLD"; then
|
|
|
|
log "Downloading world from $WORLD"
|
|
|
|
if ! get -o /tmp/world.bin "$WORLD"; then
|
|
|
|
log "ERROR: failed to download world from $WORLD"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
WORLD=/tmp/world.bin
|
2020-06-07 01:41:09 +00:00
|
|
|
fi
|
|
|
|
|
2022-01-24 04:19:25 +00:00
|
|
|
if [ -f "$WORLD" ]; then
|
|
|
|
log "Extracting world"
|
2020-06-07 01:41:09 +00:00
|
|
|
|
|
|
|
# Stage contents so that the correct subdirectory can be picked off
|
|
|
|
mkdir -p /tmp/world-data
|
2022-01-24 04:19:25 +00:00
|
|
|
if ! extract "$WORLD" /tmp/world-data; then
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-06-07 01:41:09 +00:00
|
|
|
|
2022-02-06 21:51:28 +00:00
|
|
|
baseDirs=$(find /tmp/world-data -name "level.dat" -exec dirname "{}" \;)
|
2020-12-12 14:26:32 +00:00
|
|
|
|
2022-01-24 04:19:25 +00:00
|
|
|
if ! [[ $baseDirs ]]; then
|
|
|
|
log "ERROR world content is not valid since level.dat could not be found"
|
|
|
|
exit 2
|
|
|
|
fi
|
|
|
|
|
2020-06-07 01:41:09 +00:00
|
|
|
count=$(echo "$baseDirs" | wc -l)
|
|
|
|
if [[ $count -gt 1 ]]; then
|
2022-02-06 21:51:28 +00:00
|
|
|
baseDirsNoSpigotSuffix=$(echo "$baseDirs" | sed -re 's:(_nether|_the_end)/?$::' | sort -u)
|
|
|
|
if [ $(echo "$baseDirsNoSpigotSuffix" | wc -l) -eq 1 ]; then
|
|
|
|
baseDir="$baseDirsNoSpigotSuffix"
|
|
|
|
baseName=$(basename "$baseDir")
|
|
|
|
log "Found Spigot naming conventions, taking $baseName as main dimension"
|
|
|
|
else
|
|
|
|
baseDir="$(echo "$baseDirs" | sed -n ${WORLD_INDEX:-1}p)"
|
|
|
|
baseName=$(basename "$baseDir")
|
|
|
|
log "WARN multiple levels found, picking: $baseName"
|
|
|
|
fi
|
2020-06-07 01:41:09 +00:00
|
|
|
elif [[ $count -gt 0 ]]; then
|
|
|
|
baseDir="$baseDirs"
|
2018-09-12 01:38:54 +00:00
|
|
|
else
|
2020-06-07 01:41:09 +00:00
|
|
|
log "ERROR invalid world content"
|
2020-04-06 23:59:26 +00:00
|
|
|
exit 1
|
2018-09-12 01:38:54 +00:00
|
|
|
fi
|
2022-02-06 21:51:28 +00:00
|
|
|
|
|
|
|
if [ -d "${baseDir}_nether/DIM-1" ]; then
|
|
|
|
if [ -d "$baseDir/DIM-1" ]; then
|
|
|
|
log "WARN found Nether dimension in both $baseDir and ${baseDir}_nether, picking ${baseDir}_nether"
|
|
|
|
rm -r "$baseDir/DIM-1"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
if [ -d "${baseDir}_the_end/DIM1" ]; then
|
|
|
|
if [ -d "$baseDir/DIM1" ]; then
|
|
|
|
log "WARN found End dimension in both $baseDir and ${baseDir}_the_end, picking ${baseDir}_the_end"
|
|
|
|
rm -r "$baseDir/DIM1"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
log "Copying world..."
|
2020-07-10 22:06:47 +00:00
|
|
|
rsync --remove-source-files --recursive --delete "$baseDir/" "$worldDest"
|
2022-02-06 21:51:28 +00:00
|
|
|
|
2022-01-17 02:49:15 +00:00
|
|
|
if [ "$FAMILY" = "SPIGOT" ]; then
|
2022-02-06 21:51:28 +00:00
|
|
|
if [ -d "${baseDir}_nether" ]; then
|
|
|
|
log "Copying Spigot Nether..."
|
|
|
|
rsync --remove-source-files --recursive --delete "${baseDir}_nether/" "${worldDest}_nether"
|
|
|
|
elif [ -d "$worldDest/DIM-1" ]; then
|
|
|
|
log "Moving Nether to Spigot location..."
|
|
|
|
mkdir -p "${worldDest}_nether"
|
|
|
|
mv -f "$worldDest/DIM-1" "${worldDest}_nether/"
|
|
|
|
fi
|
|
|
|
if [ -d "${baseDir}_the_end" ]; then
|
|
|
|
log "Copying Spigot End..."
|
|
|
|
rsync --remove-source-files --recursive --delete "${baseDir}_the_end/" "${worldDest}_the_end"
|
|
|
|
elif [ -d "$worldDest/DIM1" ]; then
|
|
|
|
log "Moving End to Spigot location..."
|
|
|
|
mkdir -p "${worldDest}_the_end"
|
|
|
|
mv -f "$worldDest/DIM1" "${worldDest}_the_end/"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
if [ -d "${baseDir}_nether/DIM-1" ]; then
|
|
|
|
log "Copying Spigot Nether to vanilla location..."
|
|
|
|
rsync --remove-source-files --recursive --delete "${baseDir}_nether/DIM-1" "${worldDest}/"
|
|
|
|
fi
|
|
|
|
if [ -d "${baseDir}_the_end/DIM1" ]; then
|
|
|
|
log "Copying Spigot End to vanilla location..."
|
|
|
|
rsync --remove-source-files --recursive --delete "${baseDir}_the_end/DIM1" "${worldDest}/"
|
|
|
|
fi
|
2020-12-12 14:26:32 +00:00
|
|
|
fi
|
2022-01-24 04:19:25 +00:00
|
|
|
elif [ -d "$WORLD" ]; then
|
2020-06-07 01:41:09 +00:00
|
|
|
log "Cloning world directory from $WORLD ..."
|
2020-07-10 22:06:47 +00:00
|
|
|
rsync --recursive --delete "${WORLD%/}"/ "$worldDest"
|
2022-01-24 04:19:25 +00:00
|
|
|
else
|
|
|
|
log "ERROR: world file/directory $WORLD is missing"
|
|
|
|
exit 1
|
2020-06-07 01:41:09 +00:00
|
|
|
fi
|
|
|
|
|
2022-01-17 02:49:15 +00:00
|
|
|
if [ "$FAMILY" = "SPIGOT" ]; then
|
2020-06-07 01:41:09 +00:00
|
|
|
# Reorganise if a Spigot server
|
|
|
|
log "Moving End and Nether maps to Spigot location"
|
2021-03-30 02:14:21 +00:00
|
|
|
[ -d "$worldDest/DIM1" ] && mv -f "$worldDest/DIM1" "${worldDest}_the_end"
|
|
|
|
[ -d "$worldDest/DIM-1" ] && mv -f "$worldDest/DIM-1" "${worldDest}_nether"
|
2020-06-07 01:41:09 +00:00
|
|
|
fi
|
2017-11-01 05:42:44 +00:00
|
|
|
fi
|
|
|
|
|
2022-01-04 03:59:19 +00:00
|
|
|
exec "${SCRIPTS:-/}start-setupVanillaTweaks" "$@"
|