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);
}
}
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();
}
Aggregations