Search in sources :

Example 1 with VanillaPluginManager

use of org.spongepowered.vanilla.launch.plugin.VanillaPluginManager in project SpongeCommon by SpongePowered.

the class PluginRepositorySource method loadPacks.

@Override
public void loadPacks(final Consumer<Pack> callback, final Pack.PackConstructor constructor) {
    final VanillaPluginManager pluginManager = (VanillaPluginManager) Launch.instance().pluginManager();
    // For each plugin, we create a pack. That pack might be empty.
    for (final PluginContainer pluginContainer : pluginManager.plugins()) {
        // The pack ID is prepended with "plugin-", as this will be the namespace we have to use a valid
        // character as a separator
        final String id = "plugin-" + pluginContainer.metadata().id();
        final PluginResource resource = pluginManager.resource(pluginContainer);
        // TODO: provide hook in the resource to return the file system for all resource types?
        // Also -- can we fake a FileSystem for a non-Jar (needs thinking about)....
        @Nullable Supplier<FileSystem> fileSystemSupplier = null;
        if (resource instanceof JVMPluginResource) {
            final String extension = FilenameUtils.getExtension(resource.path().getFileName().toString());
            if ("jar".equals(extension)) {
                fileSystemSupplier = ((JVMPluginResource) resource)::fileSystem;
            }
        }
        final PluginPackResources packResources = new PluginPackResources(id, pluginContainer, fileSystemSupplier);
        final Pack pack = Pack.create(id, true, () -> packResources, constructor, Pack.Position.BOTTOM, PackSource.DEFAULT);
        ((PackRepositoryBridge_Vanilla) this.repository).bridge$registerResourcePack(pluginContainer, pack);
        callback.accept(pack);
    }
}
Also used : PluginContainer(org.spongepowered.plugin.PluginContainer) JVMPluginResource(org.spongepowered.plugin.builtin.jvm.locator.JVMPluginResource) JVMPluginResource(org.spongepowered.plugin.builtin.jvm.locator.JVMPluginResource) PluginResource(org.spongepowered.plugin.PluginResource) PackRepositoryBridge_Vanilla(org.spongepowered.vanilla.bridge.server.packs.repository.PackRepositoryBridge_Vanilla) FileSystem(java.nio.file.FileSystem) VanillaPluginManager(org.spongepowered.vanilla.launch.plugin.VanillaPluginManager) Pack(net.minecraft.server.packs.repository.Pack) Nullable(org.checkerframework.checker.nullness.qual.Nullable)

Example 2 with VanillaPluginManager

use of org.spongepowered.vanilla.launch.plugin.VanillaPluginManager in project SpongeCommon by SpongePowered.

the class VanillaBootstrap method perform.

public static void perform(final String engineName, final Runnable engineStart) {
    final Stage stage = SpongeGuice.getInjectorStage(Launch.instance().injectionStage());
    SpongeCommon.logger().debug("Creating injector in stage '{}'", stage);
    final Injector bootstrapInjector = Launch.instance().createInjector();
    final SpongeLifecycle lifecycle = bootstrapInjector.getInstance(SpongeLifecycle.class);
    Launch.instance().setLifecycle(lifecycle);
    lifecycle.establishFactories();
    lifecycle.establishBuilders();
    lifecycle.initTimings();
    ((VanillaPluginManager) Launch.instance().pluginManager()).loadPlugins((VanillaPluginPlatform) Launch.instance().pluginPlatform());
    lifecycle.callConstructEvent();
    lifecycle.callRegisterFactoryEvent();
    lifecycle.callRegisterBuilderEvent();
    lifecycle.callRegisterChannelEvent();
    lifecycle.establishGameServices();
    lifecycle.establishDataKeyListeners();
    SpongePacketHandler.init((SpongeChannelManager) Sponge.channelManager());
    Launch.instance().logger().info("Loading Minecraft {}, please wait...", engineName);
    engineStart.run();
}
Also used : Injector(com.google.inject.Injector) Stage(com.google.inject.Stage) VanillaPluginManager(org.spongepowered.vanilla.launch.plugin.VanillaPluginManager) SpongeLifecycle(org.spongepowered.common.SpongeLifecycle)

Aggregations

VanillaPluginManager (org.spongepowered.vanilla.launch.plugin.VanillaPluginManager)2 Injector (com.google.inject.Injector)1 Stage (com.google.inject.Stage)1 FileSystem (java.nio.file.FileSystem)1 Pack (net.minecraft.server.packs.repository.Pack)1 Nullable (org.checkerframework.checker.nullness.qual.Nullable)1 SpongeLifecycle (org.spongepowered.common.SpongeLifecycle)1 PluginContainer (org.spongepowered.plugin.PluginContainer)1 PluginResource (org.spongepowered.plugin.PluginResource)1 JVMPluginResource (org.spongepowered.plugin.builtin.jvm.locator.JVMPluginResource)1 PackRepositoryBridge_Vanilla (org.spongepowered.vanilla.bridge.server.packs.repository.PackRepositoryBridge_Vanilla)1