Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

Commit

Permalink
kept chdir-ing into /bin/.. & not bin/.mc/..
Browse files Browse the repository at this point in the history
privelleged command for batch shell
  • Loading branch information
mickoissicko committed Jan 26, 2024
1 parent 136ca62 commit e008444
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 24 deletions.
40 changes: 18 additions & 22 deletions dependencies/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import urllib.request
import requests

versions = [
("1.20.4 (Last message, 12 years ago)", "https://piston-data.mojang.com/v1/objects/8dd1a28015f51b1803213892b50b7b4fc76e594d/server.jar"),
Expand All @@ -24,28 +24,24 @@
]

os.chdir('..')
download_directory = "/bin/.mc/"
download_directory = "bin/.mc/"
os.makedirs(download_directory, exist_ok=True)

print("Minecraft Server Downloader:")
for i, (version, _) in enumerate(versions, 1):
print(f"[{i}] {version}")
def download_server(version, url, download_directory):
file_name = os.path.join(download_directory, "server.jar")
response = requests.get(url)
with open(file_name, 'wb') as file:
file.write(response.content)
print(f"Downloaded {version} to {file_name}")

while True:
try:
choice = int(input("Choose a version to download (enter the corresponding number): "))
if 1 <= choice <= len(versions):
break
else:
print("Invalid choice. Please enter a valid number.")
except ValueError:
print("Invalid input. Please enter a number.")

selected_version = versions[choice - 1]
version_name, version_url = selected_version
download_path = os.path.join(download_directory, "server.jar")
if __name__ == "__main__":
print("Minecraft Server Downloader:")
for i, (version, _) in enumerate(versions, 1):
print(f"[{i}] {version}")

print("WARNING: STABILITY IS NOT GUARANTEED IF YOU ARE USING OLDER MINECRAFT VERSIONS!")
print(f"\nDownloading {version_name}...")
urllib.request.urlretrieve(version_url, download_path)
exit()
try:
choice = int(input("Enter the number corresponding to the version you want to download: "))
selected_version = versions[choice - 1]
download_server(*selected_version, download_directory)
except (ValueError, IndexError):
print("Invalid choice. Please enter a valid number.")
11 changes: 9 additions & 2 deletions scripts/launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ def ussr_for_win():

def mc_server():
clear_screen()
os.system('sudo python ../dependencies/config.py')

def mc_server_win():
clear_screen
os.system('python ../dependencies/config.py')

def configr():
Expand Down Expand Up @@ -142,8 +146,9 @@ def main_menu():
print("[2] Dependency setup for Arch")
print("[3] USSR for Arch")
print("[4] USSR for Windows")
print("[5] Install Minecraft")
print("[6] Configure USSR")
print("[5] Install Minecraft Server (Arc)")
print("[6] Install Minecraft Server (Win)")
print("[7] Configure USSR")
print("[X] Quit")
print("HEADS UP! Before you can proceed, please configure the paths if you haven't already.")
print("Don't know how to? See the guide: https://mick.gdn/wiki/ussr.html")
Expand All @@ -161,6 +166,8 @@ def main_menu():
elif choice == '5':
mc_server()
elif choice == '6':
mc_server_win()
elif choice == '7':
configr()
elif choice.lower() == 'x' or 'X':
break
Expand Down

0 comments on commit e008444

Please sign in to comment.