use of org.spongepowered.api.registry.AdditionalCatalogRegistryModule in project SpongeCommon by SpongePowered.
the class SpongeGameRegistry method throwRegistryEvent.
@SuppressWarnings("unchecked")
private void throwRegistryEvent(RegistryModule module) {
if (this.phase == RegistrationPhase.INIT && module instanceof AdditionalCatalogRegistryModule && (!(module instanceof SpongeAdditionalCatalogRegistryModule) || ((SpongeAdditionalCatalogRegistryModule) module).allowsApiRegistration()) && module.getClass().getAnnotation(CustomRegistrationPhase.class) == null) {
Class<? extends CatalogType> catalogClass = null;
for (Map.Entry<Class<? extends CatalogType>, CatalogRegistryModule<?>> entry : this.catalogRegistryMap.entrySet()) {
if (entry.getValue() == module) {
catalogClass = entry.getKey();
}
}
if (catalogClass == null) {
// This isn't a valid registered registry
// We should throw an exception or print out an exception, but otherwise, not going to bother at this moment.
new PrettyPrinter(60).centre().add("Unregistered RegistryModule").hr().addWrapped(60, "An unknown registry module was added to the ordered set of modules, but the " + "module itself is not registered with the GameRegistry!").add().add("%s : %s", "Registry Module", module.toString()).add().add(new Exception()).add().add("To fix this, the developer providing the module needs to register the module correctly.").trace();
return;
}
final AdditionalCatalogRegistryModule registryModule = (AdditionalCatalogRegistryModule) module;
SpongeImpl.postEvent(new SpongeGameRegistryRegisterEvent(Sponge.getCauseStackManager().getCurrentCause(), catalogClass, registryModule));
}
}
use of org.spongepowered.api.registry.AdditionalCatalogRegistryModule 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