Skip to content

Commit

Permalink
fix server builds missing files (#713)
Browse files Browse the repository at this point in the history
  • Loading branch information
htmlcsjs authored Jan 18, 2024
1 parent 2a8dbf2 commit d913aa8
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions build/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ def build(args):
copyDirs = ["/scripts", "/resources", "/config",
"/mods", "/structures", "/groovy"]
serverCopyDirs = ["/scripts", "/config", "/mods", "/structures", "/groovy"]
modURLlist = []
modClientOnly = []

if args.clean:
shutil.rmtree(basePath + "/buildOut/client/overrides",
ignore_errors=True)
Expand Down Expand Up @@ -141,23 +140,27 @@ def mkdirs(path):

continue

name = "placeholder"
if "name" in mod:
name = mod["name"]
if name[-4:] != ".jar":
name += ".jar"
modlist.append(name)
else:
modlist.append(metadata["data"].split("/")[-1])
modURLlist.append(metadata["data"])
name = metadata["data"].split("/")[-1]
url = metadata["data"]
clientOnly = False
try:
modClientOnly.append(mod["clientOnly"])
clientOnly = mod["clientOnly"]
except:
modClientOnly.append(False)
clientOnly = False

modlist.append({"name": name, "url": url, "clientOnly": clientOnly})

print("modlist compiled")
with open(basePath + "/buildOut/modlist.html", "w") as file:
data = "<html><body><h1>Modlist</h1><ul>"
for mod in modlist:
data += "<li>" + mod.split(".jar")[0] + "</li>"
data += "<li>" + mod["name"].split(".jar")[0] + "</li>"
data += "</ul></body></html>"
file.write(data)
print("modlist.html done")
Expand All @@ -173,10 +176,10 @@ def mkdirs(path):
except Exception as e:
print("Directory exists, skipping")
print("directories copied to buildOut/server")
for i, mod in enumerate(modURLlist):
jarname = mod.split("/")[-1]
if (modClientOnly[i] == True):
break
for mod in modlist:
jarname = mod["url"].split("/")[-1]
if (mod["clientOnly"] == True):
continue

if os.path.exists(os.path.join(cachepath, jarname)):
shutil.copy2(os.path.join(cachepath, jarname),
Expand All @@ -185,9 +188,9 @@ def mkdirs(path):
continue

with open(basePath + "/buildOut/server/mods/" + jarname, "w+b") as jar:
r = requests.get(mod)
r = requests.get(mod["url"])
jar.write(r.content)
print(mod + " Downloaded")
print(mod["name"] + " Downloaded")
print("Mods Downloaded")
with open(basePath + "/buildOut/server/forge-installer.jar", "w+b") as jar:
forgeVer = manifest["minecraft"]["modLoaders"][0]["id"].split("-")[-1]
Expand Down Expand Up @@ -256,15 +259,15 @@ def mkdirs(path):
print("Directory exists, skipping")
print("directories copied to buildOut/mmc/minecraft")

for i, mod in enumerate(modURLlist):
jarname = mod.split("/")[-1]
for mod in modlist:
jarname = mod["name"].split("/")[-1]
if (modClientOnly[i] == False):
break

with open(basePath + "/buildOut/mmc/minecraft/mods/" + jarname, "w+b") as jar:
r = requests.get(mod)
r = requests.get(mod["url"])
jar.write(r.content)
print(mod + " Downloaded")
print(mod["name"] + " Downloaded")

shutil.copy(basePath + "/mmc-instance-data.json",
basePath + "/buildOut/mmc/mmc-pack.json")
Expand Down

0 comments on commit d913aa8

Please sign in to comment.