use of org.spongepowered.vanilla.bridge.server.packs.repository.PackRepositoryBridge_Vanilla 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);
}
}
Aggregations