Esempio n. 1
0
 def extranatives(self, version):
     Dir(self.nativespath).create()
     # 定义一个列表来存放lib
     liblist = []
     jsonfileobj = MinecraftJson(File(self.versioncore.getjson(version)))
     for item in jsonfileobj.getlibs():
         liblist.append(item['name'] + '.jar')
     # 应对1.7.10的Forge将Minecraft加入到了Lib当中
     if jsonfileobj.getjarid():
         for item in MinecraftJson(File(self.versioncore.getjson(jsonfileobj.getjarid()))).getlibs():
             liblist.append(item['name'] + '.jar')
     for item in liblist:
         # 用正则表达式匹配lwjgl库,下下策,如果有更好的方法欢迎联系我
         lwjglre = re.compile(r'org/lwjgl/lwjgl/lwjgl-platform/(\d).(\d).(\d)/')
         # 解压文件
         if lwjglre.match(item):
             lwjgljar = ZipFile(self.lib + item)
             lwjgljar.extract_to(self.nativespath)
Esempio n. 2
0
    def getcommand(self, javapath, memories, launchobj, userobj):
        BaseMinecraft().__initcommand__(javapath, memories)
        version = self.versionname
        if userobj.Error:
            return None
        if File(launchobj.versioncore.getjson(version)).has_file() and\
           File(launchobj.versioncore.getjar(version)).has_file():

            selectversion = MinecraftJson(File(launchobj.versioncore.getjson(version)))
            self.baseshell.append("-Djava.library.path=" + launchobj.nativespath)
            self.baseshell.append("-Dhellominecraftlauncher.gamedir=" + launchobj.gamepath)

            # 定义一个列表来存放lib
            libshell = []
            for item in selectversion.getlibs():
                libshell.append(launchobj.lib + item['name'] + '.jar')

            # 应对1.7.10的Forge将Minecraft加入到了Lib当中
            if selectversion.getjarid():
                for item in MinecraftJson(File(launchobj.versioncore.getjson(selectversion.getjarid()))).getlibs():
                    libshell.append(launchobj.lib + item['name'] + '.jar')
                libshell.append(launchobj.versioncore.getjar(selectversion.getjarid()))
            else:
                libshell.append(launchobj.versioncore.getjar(version))
            self.baseshell.append("-cp")
            self.baseshell.append("\"" + (";".join(libshell)) + "\"")
            self.baseshell.append(selectversion.getmainclass())

            # MinecraftArguments的转换
            arguments = str(selectversion.getaguments()).replace('${auth_player_name}', userobj.DisplayName)\
                .replace('${auth_session}', userobj.AccessToken).replace('${version_name}', version)\
                .replace('${game_directory}', launchobj.gamepath).replace('${game_assets}', launchobj.ass)\
                .replace('${user_properties}', str(userobj.Properties)).replace('${user_type}', userobj.UserType)\
                .replace('${auth_uuid}', userobj.UUID).replace('${assets_root}', launchobj.ass)\
                .replace('${auth_access_token}', userobj.AccessToken)\
                .replace('${assets_index_name}', selectversion.getassets())

            self.baseshell.append(arguments)
            launchobj.extranatives(version)
            return " ".join(self.baseshell)
        else:
            raise NoVersionFound(version)