Search in sources :

Example 1 with PluginClassVisitor

use of org.spongepowered.server.launch.plugin.asm.PluginClassVisitor in project SpongeVanilla by SpongePowered.

the class PluginScanner method scanClassFile.

private PluginCandidate scanClassFile(InputStream in, PluginSource source) throws IOException {
    ClassReader reader = new ClassReader(in);
    PluginClassVisitor visitor = new PluginClassVisitor();
    try {
        reader.accept(visitor, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
        PluginMetadata metadata = visitor.getMetadata();
        if (metadata == null) {
            // Not a plugin class
            return null;
        }
        return new PluginCandidate(visitor.getClassName().replace('/', '.'), source, metadata);
    } catch (InvalidPluginException e) {
        logger.error("Skipping invalid plugin {} from {}", visitor.getClassName(), source, e);
    }
    return null;
}
Also used : ClassReader(org.objectweb.asm.ClassReader) PluginMetadata(org.spongepowered.plugin.meta.PluginMetadata) PluginClassVisitor(org.spongepowered.server.launch.plugin.asm.PluginClassVisitor)

Aggregations

ClassReader (org.objectweb.asm.ClassReader)1 PluginMetadata (org.spongepowered.plugin.meta.PluginMetadata)1 PluginClassVisitor (org.spongepowered.server.launch.plugin.asm.PluginClassVisitor)1