File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 1+ export class ConfigClass {
2+ file : object ;
3+ widgets : object = { } ;
4+
5+ constructor ( config_object : object ) {
6+ this . file = config_object ;
7+ }
8+
9+ public get_widgets ( ) {
10+ return this . file . config . widgets ;
11+ }
12+ }
Original file line number Diff line number Diff line change 11import JSZip from "jszip" ;
2+ import { ConfigClass } from "./config" ;
23
34export interface Datapack {
45 id : string ;
@@ -13,6 +14,7 @@ export interface Datapack {
1314 mcmeta : Record < string , unknown > ;
1415 zip : JSZip ;
1516 config : unknown | undefined ;
17+ configObject : undefined | ConfigClass ;
1618 modules : Set < Module > ;
1719}
1820
@@ -44,22 +46,25 @@ export async function loadDatapack(file: File): Promise<Datapack | string> {
4446
4547 const modules = detectModules ( zip ) ;
4648
47- let config ;
49+ let config = { } ;
4850 if ( modules . has ( Modules . DPCONFIG ) ) config = await loadDpConfig ( zip ) ;
4951
52+ let configObject = new ConfigClass ( config ) ;
53+
5054 return {
5155 id : mcmeta . pack . id || file . name ,
5256 name : mcmeta . pack . name ,
5357 description : mcmeta . pack . description ,
5458 icon,
5559 mcmeta,
5660 config,
61+ configObject,
5762 zip,
5863 modules,
5964 } ;
6065}
6166
62- async function loadDpConfig ( datapackZip : JSZip ) : Promise < unknown > {
67+ async function loadDpConfig ( datapackZip : JSZip ) : Promise < Object > {
6368 const dpConfigText = await datapackZip . file ( "dpconfig.json" ) ?. async ( "string" ) ;
6469 if ( dpConfigText ) return JSON . parse ( dpConfigText ) ;
6570 else return { } ;
You can’t perform that action at this time.
0 commit comments