use of org.lanternpowered.server.event.registry.LanternGameRegistryRegisterEvent in project LanternServer by LanternPowered.
the class LanternGameRegistry method registerModulePhase.
@SuppressWarnings("unchecked")
private void registerModulePhase() {
syncModules();
for (Class<? extends RegistryModule> moduleClass : this.orderedModules) {
if (!this.classMap.containsKey(moduleClass)) {
throw new IllegalStateException("Something funky happened! The module " + moduleClass + " is required but seems to be missing.");
}
tryModulePhaseRegistration(this.classMap.get(moduleClass));
if (this.phase == RegistrationPhase.INIT) {
Map.Entry<Class<? extends CatalogType>, CatalogRegistryModule<?>> selectedEntry = null;
for (Map.Entry<Class<? extends CatalogType>, CatalogRegistryModule<?>> entry : this.catalogRegistryMap.entrySet()) {
if (entry.getValue().getClass() == moduleClass) {
selectedEntry = entry;
break;
}
}
if (selectedEntry == null) {
continue;
}
final CatalogRegistryModule module = selectedEntry.getValue();
if (module instanceof AdditionalCatalogRegistryModule && module.getClass().getAnnotation(CustomRegistrationPhase.class) == null) {
this.game.getEventManager().post(new LanternGameRegistryRegisterEvent(CauseStack.current().getCurrentCause(), selectedEntry.getKey(), (AdditionalCatalogRegistryModule) module));
}
}
}
registerAdditionalPhase();
}
Aggregations