use of org.lanternpowered.server.plugin.asm.PluginClassVisitor in project LanternServer by LanternPowered.
the class PluginScanner method scanClassFile.
private PluginCandidate scanClassFile(InputStream in, @Nullable Path source) throws IOException {
final ClassReader reader = new ClassReader(in);
final PluginClassVisitor visitor = new PluginClassVisitor();
try {
reader.accept(visitor, ClassReader.SKIP_CODE | ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
final 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;
}
Aggregations