@@ -12,33 +12,33 @@ def main():
12
12
args = parser .parse_args ()
13
13
14
14
# Load versions file
15
- with open ("versions.json" ) as f :
16
- versions = json .load (f )
15
+ with open (f"versions/{ args .type } .txt" , 'r' ) as f :
16
+ version = f .read ().strip ()
17
+
17
18
18
19
# Set URL
19
- url = f"https://minecraft.azureedge.net/bin-linux{ "" if args .type == "stable" else "-preview" } /bedrock-server-{ versions [ args . type ] } .zip" if args . type in versions else None
20
+ url = f"https://minecraft.azureedge.net/bin-linux{ "" if args .type == "stable" else "-preview" } /bedrock-server-{ version } .zip"
20
21
21
- if url :
22
- print (f"Downloading { url } ..." )
23
- response = requests .get (url )
24
- response .raise_for_status ()
22
+ # Download and extract server
23
+ print (f"Downloading { url } ..." )
24
+ response = requests .get (url )
25
+ response .raise_for_status ()
25
26
26
- print ("Extracting..." )
27
- with zipfile .ZipFile (io .BytesIO (response .content )) as z :
28
- z .extractall (os .path .join ("minecraft_server" ))
27
+ print ("Extracting..." )
28
+ with zipfile .ZipFile (io .BytesIO (response .content )) as z :
29
+ z .extractall (os .path .join ("minecraft_server" ))
29
30
30
- print ("Setting permissions..." )
31
- os .chmod (os .path .join ("minecraft_server" , "bedrock_server" ), 0o777 )
31
+ print ("Setting permissions..." )
32
+ os .chmod (os .path .join ("minecraft_server" , "bedrock_server" ), 0o777 )
32
33
33
- # Create Base World Directory for Volume Mount
34
- os .makedirs (os .path .join ("minecraft_server" , "worlds" , "Bedrock level" ), exist_ok = True )
34
+ # Create Base World Directory for Volume Mount
35
+ os .makedirs (os .path .join ("minecraft_server" , "worlds" , "Bedrock level" ), exist_ok = True )
35
36
36
- print ("Cleaning up..." )
37
+ print ("Cleaning up..." )
37
38
38
39
39
- print ("Done." )
40
- else :
41
- print (f"Invalid server type: { args .type } . Please specify 'stable' or 'preview'." )
40
+ print ("Done." )
41
+
42
42
43
43
if __name__ == "__main__" :
44
44
main ()
0 commit comments