37 lines
833 B
TypeScript
37 lines
833 B
TypeScript
import { Identifier, SingleRegistry } from './core';
|
|
import { BlockRegistry } from './block';
|
|
import { ItemRegistry } from './item';
|
|
|
|
/**
|
|
* Registry
|
|
*/
|
|
export abstract class Registry {
|
|
/**
|
|
* Block Registry
|
|
*/
|
|
static BLOCK = BlockRegistry.INSTANCE;
|
|
/**
|
|
* Item Registry
|
|
*/
|
|
static ITEM = ItemRegistry.INSTANCE;
|
|
|
|
/**
|
|
* Register Object
|
|
* @param registry Target Registry
|
|
* @param id ID
|
|
* @param obj Object
|
|
*/
|
|
static register<T>(registry: SingleRegistry<T>, id: Identifier, obj: T): T {
|
|
registry.register(id, obj);
|
|
return obj;
|
|
}
|
|
|
|
/**
|
|
* Get Object From Registry
|
|
* @param registry Target Registry
|
|
* @param id ID
|
|
*/
|
|
static get<T>(registry: SingleRegistry<T>, id: Identifier): T {
|
|
return registry.get(id);
|
|
}
|
|
} |