From d3e6d3e579907d5c134419b9203402c583ce58e2 Mon Sep 17 00:00:00 2001 From: ME1312 Date: Sat, 22 Aug 2020 22:11:05 -0400 Subject: [PATCH] Fix some issues with restore points in SubCreator --- SubServers.Creator/src/Forge/build.sh | 34 +++++++++---------- SubServers.Creator/src/Paper/build.sh | 30 ++++++++++++---- SubServers.Creator/src/Sponge/build.sh | 15 ++++---- .../ME1312/SubServers/Host/SubCommand.java | 2 +- 4 files changed, 50 insertions(+), 31 deletions(-) diff --git a/SubServers.Creator/src/Forge/build.sh b/SubServers.Creator/src/Forge/build.sh index 5119fc21..5b3a8aaa 100644 --- a/SubServers.Creator/src/Forge/build.sh +++ b/SubServers.Creator/src/Forge/build.sh @@ -18,6 +18,20 @@ function __DL() { curl -o "$1" "$2"; return $? fi } +function __Restore() { + if [[ -f "Forge.old.jar.x" ]]; then + if [[ -f "Forge.jar" ]]; then + rm -Rf Forge.jar + fi + mv Forge.old.jar.x Forge.jar + fi + if [[ -f "mods/Sponge.old.jar.x" ]]; then + if [[ -f "mods/Sponge.jar" ]]; then + rm -Rf mods/Sponge.jar + fi + mv mods/Sponge.old.jar.x mods/Sponge.jar + fi +} echo Downloading the Minecraft Forge Installer... __DL "forge-$mcf_version-installer.jar" "http://files.minecraftforge.net/maven/net/minecraftforge/forge/$mcf_version/forge-$mcf_version-installer.jar"; __RETURN=$? if [[ $__RETURN -eq 0 ]]; then @@ -25,12 +39,6 @@ if [[ $__RETURN -eq 0 ]]; then "$java" -jar "forge-$mcf_version-installer.jar" --installServer; __RETURN=$? if [[ $__RETURN -eq 0 ]]; then echo Cleaning Up... - if [[ -f "Forge.jar" ]]; then - if [[ -f "Forge.old.jar.x" ]]; then - rm -Rf Forge.old.jar.x - fi - mv Forge.jar Forge.old.jar.x - fi if [[ ! -d "mods" ]]; then mkdir mods fi @@ -51,23 +59,13 @@ if [[ $__RETURN -eq 0 ]]; then exit 0 else echo ERROR: Failed downloading Sponge. Is SpongePowered.org down? - if [[ -f "mods/Sponge.old.jar.x" ]]; then - if [[ -f "mods/Sponge.jar" ]]; then - rm -Rf mods/Sponge.jar - fi - mv mods/Sponge.old.jar.x mods/Sponge.jar - fi - if [[ -f "Forge.old.jar.x" ]]; then - if [[ -f "Forge.jar" ]]; then - rm -Rf Forge.jar - fi - mv Forge.old.jar.x Forge.jar - fi + __Restore rm -Rf "$0" exit 5 fi else echo ERROR: The Installer exited with an error. Please try again + __Restore rm -Rf "forge-$mcf_version-installer.jar" rm -Rf "forge-$mcf_version-installer.jar.log" rm -Rf "$0" diff --git a/SubServers.Creator/src/Paper/build.sh b/SubServers.Creator/src/Paper/build.sh index 88629e31..9c2b4cda 100644 --- a/SubServers.Creator/src/Paper/build.sh +++ b/SubServers.Creator/src/Paper/build.sh @@ -14,6 +14,14 @@ function __DL() { curl -o "$1" "$2"; return $? fi } +function __Restore() { + if [[ -f "Paper.old.jar.x" ]]; then + if [[ -f "Paper.jar" ]]; then + rm -Rf Paper.jar + fi + mv Paper.old.jar.x Paper.jar + fi +} echo Downloading Paper... if [[ -f "Paper.jar" ]]; then if [[ -f "Paper.old.jar.x" ]]; then @@ -23,12 +31,22 @@ if [[ -f "Paper.jar" ]]; then fi __DL Paper.jar "https://papermc.io/api/v1/paper/$version/latest/download"; __RETURN=$? if [[ $__RETURN -eq 0 ]]; then - echo Cleaning Up... - rm -Rf "$0" - exit 0 + if [[ $(stat -c%s "Paper.jar") -ge 1000000 ]]; then + echo Cleaning Up... + rm -Rf "$0" + exit 0 + else + echo ERROR: Received invalid jarfile when requesting Paper version $version: + cat Paper.jar + printf "\n" + __Restore + rm -Rf "$0" + exit 4 + fi else - echo ERROR: Failed downloading Paper. Is PaperMC.io down? - rm -Rf "$0" - exit 3 + echo ERROR: Failed downloading Paper. Is PaperMC.io down? + __Restore + rm -Rf "$0" + exit 3 fi exit 2 \ No newline at end of file diff --git a/SubServers.Creator/src/Sponge/build.sh b/SubServers.Creator/src/Sponge/build.sh index 8ab766ed..1797186f 100644 --- a/SubServers.Creator/src/Sponge/build.sh +++ b/SubServers.Creator/src/Sponge/build.sh @@ -14,6 +14,14 @@ function __DL() { curl -o "$1" "$2"; return $? fi } +function __Restore() { + if [[ -f "Sponge.old.jar.x" ]]; then + if [[ -f "Sponge.jar" ]]; then + rm -Rf Sponge.jar + fi + mv Sponge.old.jar.x Sponge.jar + fi +} echo Downloading SpongeVanilla... if [[ -f "Sponge.jar" ]]; then if [[ -f "Sponge.old.jar.x" ]]; then @@ -28,12 +36,7 @@ if [[ $__RETURN -eq 0 ]]; then exit 0 else echo ERROR: Failed downloading Sponge. Is SpongePowered.org down? - if [[ -f "Sponge.old.jar.x" ]]; then - if [[ -f "Sponge.jar" ]]; then - rm -Rf Sponge.jar - fi - mv Sponge.old.jar.x Sponge.jar - fi + __Restore rm -Rf "$0" exit 3 fi diff --git a/SubServers.Host/src/net/ME1312/SubServers/Host/SubCommand.java b/SubServers.Host/src/net/ME1312/SubServers/Host/SubCommand.java index 692ffd6a..bdc1e36f 100644 --- a/SubServers.Host/src/net/ME1312/SubServers/Host/SubCommand.java +++ b/SubServers.Host/src/net/ME1312/SubServers/Host/SubCommand.java @@ -779,7 +779,7 @@ public class SubCommand { sender.sendMessage("Invalid port number"); break; case 0: - sender.sendMessage("Creating subserver " + args[1]); + sender.sendMessage("Creating subserver " + args[0]); break; } }));