New logger with color and specific types. Code cleanup (#3108)

This commit is contained in:
Tristan
2024-10-22 23:04:38 +02:00
committed by GitHub
parent a356c6810e
commit bef7b4719f
38 changed files with 424 additions and 428 deletions

View File

@@ -27,7 +27,7 @@ if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] );
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"
logError "Failed to download world from $WORLD"
exit 1
fi
WORLD=/tmp/world.bin
@@ -39,14 +39,14 @@ if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] );
# Stage contents so that the correct subdirectory can be picked off
mkdir -p /tmp/world-data
if ! extract "$WORLD" /tmp/world-data; then
log "ERROR extracting world from $WORLD"
logError "Extracting world from $WORLD"
exit 1
fi
baseDirs=$(find /tmp/world-data -name "level.dat" -exec dirname "{}" \;)
if ! [[ $baseDirs ]]; then
log "ERROR world content is not valid since level.dat could not be found"
logError "World content is not valid since level.dat could not be found"
exit 2
fi
@@ -60,24 +60,24 @@ if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] );
else
baseDir="$(echo "$baseDirs" | sed -n ${WORLD_INDEX:-1}p)"
baseName=$(basename "$baseDir")
log "WARN multiple levels found, picking: $baseName"
logWarning "Multiple levels found, picking: $baseName"
fi
elif [[ $count -gt 0 ]]; then
baseDir="$baseDirs"
else
log "ERROR invalid world content"
logError "Invalid world content"
exit 1
fi
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"
logWarning "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"
logWarning "Found End dimension in both $baseDir and ${baseDir}_the_end, picking ${baseDir}_the_end"
rm -r "$baseDir/DIM1"
fi
fi
@@ -116,7 +116,7 @@ if [[ "$WORLD" ]] && ( isTrue "${FORCE_WORLD_COPY}" || [ ! -d "$worldDest" ] );
log "Cloning world directory from $WORLD ..."
rsync --recursive --delete "${WORLD%/}"/ "$worldDest"
else
log "ERROR: world file/directory $WORLD is missing"
logError "World file/directory $WORLD is missing"
exit 1
fi