Example #1
0
def downloadMCplusLibs(side,mcversion):
    print("Preparing to get Minecraft jar and its libs")
    version = urllib2.urlopen("http://s3.amazonaws.com/Minecraft.Download/versions/versions.json")
    versionJson = json.load(version)
    version.close()
    versions = []
    for x in versionJson["versions"]:
        versions.append(x["id"])
    if mcversion not in versions:
        print("[ERROR] The version you supplied in the config does not exist!: %s" % mcversion)
        exit(-1)
    if side == "Client" or side == "Both":
        sysAdd = ""
        if "Win" in osutils.getOS():
            sysAdd = "/AppData/Roaming"
        print("Searching for Client jar in %s" % expanduser("~")+sysAdd+"/.minecraft")
        jar = whereis.whereis(mcversion+".jar",expanduser("~")+sysAdd+"/.minecraft",["assets","saves"])
        if jar is not None:
            print("Jar located at %s." % jar[0])
            print("Client jar located copying to working dir.");
            ssjb.file.cp(jar[0]+"/"+mcversion+".jar",os.getcwd()+"/jars/versions/"+mcversion+"/"+mcversion+".jar")
        else:
            print("Client jar not loacted attemping to download.")
            try:
                downloader.DownloadZip(os.getcwd()+"/jars/versions/"+mcversion+"/"+mcversion+".jar","http://s3.amazonaws.com/Minecraft.Download/versions/" + mcversion+"/"+mcversion+".jar",mcversion + " Client Jar")
            except:
                print("Download failed. Please check your internet connection.")
                exit(-1)
        libjson = urllib2.urlopen("http://s3.amazonaws.com/Minecraft.Download/versions/<version>/<version>.json".replace("<version>",mcversion))
        libs = json.load(libjson)["libraries"]
        libjson.close()
        print("Searching for libraries in your .minecraft. Will download if they ar enot present")
        for x in libs:
            libinfo = x["name"].split(":")
            if "natives" in x.keys():
                if "Win" in osutils.getOS():
                    downloadLib(libinfo[0],libinfo[1],libinfo[2],"-"+x["natives"]["windows"].replace("${arch}",osutils.getOS().split("-")[1]))
                if "Linux" in osutils.getOS():
                    downloadLib(libinfo[0],libinfo[1],libinfo[2],"-"+x["natives"]["linux"].replace("${arch}",osutils.getOS().split("-")[1]))
                if "Osx" in osutils.getOS():
                    downloadLib(libinfo[0],libinfo[1],libinfo[2],"-"+x["natives"]["osx"].replace("${arch}",osutils.getOS().split("-")[1]))
            else:
                downloadLib(libinfo[0],libinfo[1],libinfo[2])
    if side == "Server" or side == "Both":
        print("Downloading Server jar")
        downloader.DownloadZip(os.getcwd()+"/jars/"+mcversion+"-server.jar",
                               " http://s3.amazonaws.com/Minecraft.Download/versions/"+mcversion+"/minecraft_server." +
                               mcversion+".jar",mcversion + " Server Jar")
Example #2
0
def downloadLib(package,name,version,native=""):
    #print("Attemping to get %s from your Minecraft installation."%name)
    sysAdd = ""
    if "Win" in osutils.getOS():
        sysAdd = "\\AppData\\Roaming"
    NatAdd = ""
    if downloader.isZip(os.getcwd()+"/jars/libraries/"+package.replace(".","/")+"/"+name+"/"+version+"/"+name +"-"+version+NatAdd+".jar"):
        #print("Skipped")
        pass
    if native is not "":
        NatAdd = native
    lib = whereis.whereis(name +"-"+version+NatAdd+".jar",expanduser("~")+sysAdd+"/.minecraft/libraries")
    if lib is not None:
       # print("%s located at %s." % (name,lib[0]))
        ssjb.file.cp(lib[0]+"/"+name +"-"+version+NatAdd+".jar",os.getcwd()+"/jars/libraries/"+package.replace(".","/")+"/"+name+"/"+version+"/"+name +"-"+version+NatAdd+".jar")
    else:
         downloader.DownloadZip(os.getcwd()+"/jars/libraries/"+package.replace(".","/")+"/"+name+"/"+version+"/"+name +"-"+version+NatAdd+".jar","https://libraries.minecraft.net/"+package.replace(".","/")+"/"+name+"/"+version+"/"+name+"-"+version+NatAdd+".jar",name)