Search in sources :

Example 1 with FactoryRegistry

use of org.spongepowered.api.registry.FactoryRegistry in project LanternServer by LanternPowered.

the class LanternGameRegistry method registerFactories.

private void registerFactories() {
    final List<FactoryRegistry<?, ?>> factoryRegistries = new ArrayList<>();
    factoryRegistries.add(new ResourcePackFactoryModule());
    factoryRegistries.add(new TimingsFactoryRegistryModule());
    try {
        for (FactoryRegistry<?, ?> registry : factoryRegistries) {
            RegistryHelper.setFactory(registry.getFactoryOwner(), registry.provideFactory());
            registry.initialize();
        }
    } catch (Exception e) {
        this.game.getLogger().error("Could not initialize a factory!", e);
    }
}
Also used : ResourcePackFactoryModule(org.lanternpowered.server.game.registry.factory.ResourcePackFactoryModule) FactoryRegistry(org.spongepowered.api.registry.FactoryRegistry) ArrayList(java.util.ArrayList) TimingsFactoryRegistryModule(org.lanternpowered.server.game.registry.factory.TimingsFactoryRegistryModule) CyclicGraphException(org.lanternpowered.server.util.graph.CyclicGraphException) IOException(java.io.IOException) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 2 with FactoryRegistry

use of org.spongepowered.api.registry.FactoryRegistry in project SpongeCommon by SpongePowered.

the class CommonModuleRegistry method registerFactories.

private void registerFactories() {
    final List<FactoryRegistry<?, ?>> factoryRegistries = new ArrayList<>();
    factoryRegistries.add(new ResourcePackFactoryModule());
    factoryRegistries.add(new TimingsFactoryModule());
    try {
        Field modifierField = Field.class.getDeclaredField("modifiers");
        modifierField.setAccessible(true);
        for (FactoryRegistry<?, ?> registry : factoryRegistries) {
            RegistryHelper.setFactory(registry.getFactoryOwner(), registry.provideFactory());
            registry.initialize();
        }
    } catch (Exception e) {
        SpongeImpl.getLogger().error("Could not initialize a factory!", e);
    }
}
Also used : TimingsFactoryModule(org.spongepowered.common.registry.factory.TimingsFactoryModule) Field(java.lang.reflect.Field) ResourcePackFactoryModule(org.spongepowered.common.registry.factory.ResourcePackFactoryModule) FactoryRegistry(org.spongepowered.api.registry.FactoryRegistry) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)2 FactoryRegistry (org.spongepowered.api.registry.FactoryRegistry)2 IOException (java.io.IOException)1 Field (java.lang.reflect.Field)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ResourcePackFactoryModule (org.lanternpowered.server.game.registry.factory.ResourcePackFactoryModule)1 TimingsFactoryRegistryModule (org.lanternpowered.server.game.registry.factory.TimingsFactoryRegistryModule)1 CyclicGraphException (org.lanternpowered.server.util.graph.CyclicGraphException)1 ResourcePackFactoryModule (org.spongepowered.common.registry.factory.ResourcePackFactoryModule)1 TimingsFactoryModule (org.spongepowered.common.registry.factory.TimingsFactoryModule)1