-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathfabric_install.py
58 lines (48 loc) · 1.91 KB
/
fabric_install.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import os
import json
import sys
import requests
import subprocess
from util import *
import xml.etree.ElementTree as et
def get_latest_ver():
url = 'https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml'
outpath = '/tmp/fabric-versions.xml'
resp = download(url, outpath)
if resp != 200:
print("Error %d trying to download Fabric version list" % resp)
return None
xml_tree = et.parse(outpath)
root = xml_tree.getroot()
ver_info = xml_tree.find('versioning')
release_ver = ver_info.find('release')
return release_ver.text
def main(manifest, mcver, mlver, packname, mc_dir, manual):
print("Installing Fabric modloader")
installer_ver = get_latest_ver()
if installer_ver is None:
print("Failed to acquire Fabric installer version")
sys.exit(2)
url = 'https://maven.fabricmc.net/net/fabricmc/fabric-installer/%s/fabric-installer-%s.jar' \
% (installer_ver, installer_ver)
outpath = '/tmp/fabric-%s-installer.jar' % installer_ver
if not os.path.exists(outpath):
resp = download(url, outpath)
if resp != 200:
print("Got error %d trying to download Fabric" % resp)
sys.exit(2)
args = ['java', '-jar', outpath, 'client', '-snapshot', '-dir', mc_dir,
'-loader', mlver, '-mcversion', mcver]
if manual:
# I guess they want manual mode for some reason
print("Using the manual installer!")
print("***** NEW: INSTALL TO THE MAIN .MINECRAFT DIRECTORY *****")
print("***** (Just hit 'OK' with the default settings) *****")
subprocess.run(['java', '-jar', outpath])
else:
subprocess.run(args)
if not os.path.exists(mc_dir + '/versions/' + get_version_id(mcver, mlver)):
print("Forge installation failed.")
sys.exit(3)
def get_version_id(mcver, mlver):
return 'fabric-loader-%s-%s' % (mlver, mcver)