mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-08-04 04:26:15 -04:00
improve assets properties generation code
This commit is contained in:
parent
43eb1ff4d1
commit
b4ed972efd
@ -11,8 +11,7 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"index_version": {
|
||||
"type": "string",
|
||||
"pattern": "\\d+\\.\\d{1,2}"
|
||||
"type": "string"
|
||||
},
|
||||
"index_hash": {
|
||||
"$ref": "#/definitions/hash"
|
||||
|
@ -17,11 +17,9 @@ import de.bixilon.kutil.reflection.ReflectionUtil.forceInit
|
||||
import de.bixilon.minosoft.assets.InvalidAssetException
|
||||
import de.bixilon.minosoft.assets.minecraft.JarAssetsManager
|
||||
import de.bixilon.minosoft.config.profile.profiles.resources.ResourcesProfileManager
|
||||
import de.bixilon.minosoft.protocol.packets.registry.PacketMapping
|
||||
import de.bixilon.minosoft.protocol.protocol.PacketDirections
|
||||
import de.bixilon.minosoft.protocol.versions.Version
|
||||
import de.bixilon.minosoft.protocol.versions.VersionTypes
|
||||
import de.bixilon.minosoft.util.logging.Log
|
||||
import org.objenesis.ObjenesisStd
|
||||
import kotlin.system.exitProcess
|
||||
|
||||
object AssetsPropertiesGenerator {
|
||||
@ -29,17 +27,19 @@ object AssetsPropertiesGenerator {
|
||||
@JvmStatic
|
||||
fun main(args: Array<String>) {
|
||||
val stream = System.out
|
||||
System.setOut(System.err)
|
||||
Log::class.java.forceInit()
|
||||
if (args.size != 2) {
|
||||
throw IllegalArgumentException("Usage: application <version id> <client jar hash>")
|
||||
Log.ASYNC_LOGGING = false
|
||||
if (args.size != 1) {
|
||||
throw IllegalArgumentException("Usage: application <client jar hash>")
|
||||
}
|
||||
// create profile to not make crashes (or load an actual profile)
|
||||
val profile = ResourcesProfileManager.createProfile()
|
||||
profile.verify = false
|
||||
val (versionId, clientJarHash) = args
|
||||
val (clientJarHash) = args
|
||||
|
||||
val version = Version(versionId, -1, -1, VersionTypes.APRIL_FOOL, PacketMapping(PacketDirections.SERVER_TO_CLIENT), PacketMapping(PacketDirections.CLIENT_TO_SERVER))
|
||||
val assetsManager = JarAssetsManager("829c3804401b0727f70f73d4415e162400cbe57b", clientJarHash, profile, version)
|
||||
val version = ObjenesisStd().newInstance(Version::class.java)
|
||||
val assetsManager = JarAssetsManager("0000000000000000000000000000000000000000", clientJarHash, profile, version)
|
||||
try {
|
||||
assetsManager.load()
|
||||
} catch (exception: InvalidAssetException) {
|
||||
|
File diff suppressed because one or more lines are too long
@ -8,6 +8,22 @@
|
||||
# You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
#
|
||||
# This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
|
||||
import subprocess
|
||||
import ujson
|
||||
@ -24,8 +40,8 @@ VERSION_MANIFEST = ujson.loads(urllib.request.urlopen('https://launchermeta.moja
|
||||
PIXLYZER_INDEX = ujson.loads(urllib.request.urlopen('https://gitlab.bixilon.de/bixilon/pixlyzer-data/-/raw/master/mbf_index.min.json?inline=false').read().decode("utf-8"))
|
||||
|
||||
|
||||
def generate_jar_assets(version_id, assets_properties):
|
||||
process = subprocess.Popen(r'./gradlew -q assetsProperties --args="\"%s\" \"%s\""' % (version_id, assets_properties["client_jar_hash"]), shell=True, cwd='../', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
def generate_jar_assets(assets_properties):
|
||||
process = subprocess.Popen(r'./gradlew -q assetsProperties --args="\"%s\""' % (assets_properties["client_jar_hash"]), shell=True, cwd='../', stdout=subprocess.PIPE, stderr=subprocess.PIPE)
|
||||
exit_code = process.wait()
|
||||
if exit_code != 0:
|
||||
print(process.stdout.read().decode('utf-8'))
|
||||
@ -35,7 +51,7 @@ def generate_jar_assets(version_id, assets_properties):
|
||||
|
||||
(hash, tar_bytes) = process.stdout.read().decode('utf-8').split(":")
|
||||
assets_properties["jar_assets_hash"] = hash
|
||||
assets_properties["jar_assets_tar_bytes"] = tar_bytes
|
||||
assets_properties["jar_assets_tar_bytes"] = int(tar_bytes)
|
||||
|
||||
|
||||
def generate_version(version):
|
||||
@ -67,10 +83,10 @@ def generate_version(version):
|
||||
|
||||
if "jar_assets_hash" not in assets_properties:
|
||||
try:
|
||||
generate_jar_assets(version["id"], assets_properties)
|
||||
generate_jar_assets(assets_properties)
|
||||
changed = True
|
||||
except Exception:
|
||||
print("%s failed!" % version["id"])
|
||||
except Exception as e:
|
||||
print("%s failed: %s" % (version["id"], str(e)))
|
||||
return
|
||||
|
||||
return changed
|
||||
|
Loading…
x
Reference in New Issue
Block a user