full suport for models and hotloading Plugins
This commit is contained in:
@@ -41,6 +41,7 @@ from .zips import (
|
||||
read_models_manifest,
|
||||
read_pack_meta,
|
||||
read_pack_mcmeta,
|
||||
read_plugins_manifest,
|
||||
)
|
||||
|
||||
|
||||
@@ -331,6 +332,7 @@ def project_detail(request, slug):
|
||||
models_manifest = None
|
||||
logical_manifest = None
|
||||
mods_manifest = None
|
||||
plugins_manifest = None
|
||||
anim_stats = None
|
||||
latest = versions.first()
|
||||
if project.category == 'guide' and latest is not None:
|
||||
@@ -340,6 +342,7 @@ def project_detail(request, slug):
|
||||
models_manifest = latest.models_manifest or None
|
||||
logical_manifest = latest.logical_manifest or None
|
||||
mods_manifest = latest.mods_manifest or None
|
||||
plugins_manifest = latest.plugins_manifest or None
|
||||
if animation_manifest:
|
||||
anims = animation_manifest.get('animations') or []
|
||||
entity_count = sum(1 for a in anims if a.get('type') == 'Entity x Player')
|
||||
@@ -353,6 +356,14 @@ def project_detail(request, slug):
|
||||
'tags': sorted({t for a in anims for t in (a.get('content_tags') or [])}),
|
||||
}
|
||||
|
||||
autoload_plugins_json = ''
|
||||
if plugins_manifest:
|
||||
members = [
|
||||
p['member'] for p in plugins_manifest.get('plugins', [])
|
||||
if p.get('autoload') and p.get('member')
|
||||
]
|
||||
autoload_plugins_json = json.dumps(members)
|
||||
|
||||
context = {
|
||||
'project': project,
|
||||
'versions': versions,
|
||||
@@ -364,6 +375,8 @@ def project_detail(request, slug):
|
||||
'models_manifest': models_manifest,
|
||||
'logical_manifest': logical_manifest,
|
||||
'mods_manifest': mods_manifest,
|
||||
'plugins_manifest': plugins_manifest,
|
||||
'autoload_plugins_json': autoload_plugins_json,
|
||||
'anim_stats': anim_stats,
|
||||
}
|
||||
return render(request, 'library/project_detail.html', context)
|
||||
@@ -638,6 +651,7 @@ def _reparse_version(version):
|
||||
version.animation_manifest = read_animation_manifest(path) or {}
|
||||
version.models_manifest = read_models_manifest(path, version.project.category) or {}
|
||||
version.logical_manifest = read_logical_manifest(path) or {}
|
||||
version.plugins_manifest = read_plugins_manifest(path) or {} if version.project.category == 'model' else {}
|
||||
manifest = parse_mods_manifest(path, release.file.original_filename)
|
||||
version.mods_manifest = manifest if manifest.get('files') else {}
|
||||
fmt, desc = read_pack_mcmeta(path)
|
||||
@@ -659,6 +673,7 @@ def _finalize_version(project, version_name, changelog, temp_uploads, actor):
|
||||
pack_format = None
|
||||
pack_description = ''
|
||||
mods_manifest = {}
|
||||
plugins_manifest = None
|
||||
animation_id = ''
|
||||
animation_manifest = None
|
||||
models_manifest = None
|
||||
@@ -701,6 +716,8 @@ def _finalize_version(project, version_name, changelog, temp_uploads, actor):
|
||||
manifest = parse_mods_manifest(path, index.original_filename)
|
||||
if manifest.get('files'):
|
||||
mods_manifest = manifest
|
||||
if plugins_manifest is None and project.category == 'model':
|
||||
plugins_manifest = read_plugins_manifest(path)
|
||||
|
||||
update_fields = []
|
||||
if pack_format is not None:
|
||||
@@ -710,6 +727,9 @@ def _finalize_version(project, version_name, changelog, temp_uploads, actor):
|
||||
if mods_manifest:
|
||||
version.mods_manifest = mods_manifest
|
||||
update_fields.append('mods_manifest')
|
||||
if plugins_manifest is not None:
|
||||
version.plugins_manifest = plugins_manifest
|
||||
update_fields.append('plugins_manifest')
|
||||
if animation_id:
|
||||
version.animation_id = animation_id
|
||||
update_fields.append('animation_id')
|
||||
|
||||
Reference in New Issue
Block a user