Question can import skulix library to plugin?

ungsan

New member
Apr 6, 2024
2
0
1
I added dependeny, imported to library, but I still get this error

java.lang.NoClassDefFoundError: org/sikuli/script/Screen

on this code
Code:
@Override
public void onEnable() {
    Screen screen= new Screen();
}

added dependency

Code:
<dependencies>
    <dependency>
        <groupId>io.papermc.paper</groupId>
        <artifactId>paper-api</artifactId>
        <version>1.20.1-R0.1-SNAPSHOT</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.sikulix</groupId>
        <artifactId>sikulixapi</artifactId>
        <version>2.0.5</version>
    </dependency>
</dependencies>

but still get that error, I just want to know its possible or impossible..
 

ungsan

New member
Apr 6, 2024
2
0
1
You will have to shade (and relocate) the API into your plugin, for example by using the maven shade plugin.

Code:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>user.woongsan</groupId>
    <artifactId>tempplugin</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <name>tempplugin</name>

    <properties>
        <java.version>1.8</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <relocations>
                                <relocation>
                                    <pattern>org.sikuli.script</pattern>
                                    <shadedPattern>org.shaded.script</shadedPattern>
                                    <includes>
                                        <include>org.sikuli.script.*</include>
                                    </includes>
                                </relocation>
                            </relocations>

                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>


    <repositories>
        <repository>
            <id>papermc-repo</id>
            <url>https://repo.papermc.io/repository/maven-public/</url>
        </repository>
        <repository>
            <id>sonatype</id>
            <url>https://oss.sonatype.org/content/groups/public/</url>
        </repository>
    </repositories>

    <dependencies>
        <dependency>
            <groupId>io.papermc.paper</groupId>
            <artifactId>paper-api</artifactId>
            <version>1.20.1-R0.1-SNAPSHOT</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>com.sikulix</groupId>
            <artifactId>sikulixapi</artifactId>
            <version>2.0.5</version>
        </dependency>

    </dependencies>
</project>

can you check this file?
I tried, and move shaded.jar file to plugin, and get new error

Code:
[23:42:59 ERROR]: [DirectoryProviderSource] Error loading plugin: Directory 'plugins\tempplugin-1.0-SNAPSHOT-shaded.jar' failed to load!
java.lang.RuntimeException: Directory 'plugins\tempplugin-1.0-SNAPSHOT-shaded.jar' failed to load!
        at io.papermc.paper.plugin.provider.source.FileProviderSource.registerProviders(FileProviderSource.java:59) ~[paper-1.20.1.jar:git-Paper-115]
        at io.papermc.paper.plugin.provider.source.DirectoryProviderSource.lambda$registerProviders$1(DirectoryProviderSource.java:34) ~[paper-1.20.1.jar:git-Paper-115]
        at java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184) ~[?:?]
        at java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179) ~[?:?]
        at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]
        at java.util.Iterator.forEachRemaining(Iterator.java:133) ~[?:?]
        at java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939) ~[?:?]
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[?:?]
        at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[?:?]
        at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151) ~[?:?]
        at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174) ~[?:?]
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
        at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[?:?]
        at io.papermc.paper.plugin.provider.source.DirectoryProviderSource.registerProviders(DirectoryProviderSource.java:32) ~[paper-1.20.1.jar:git-Paper-115]
        at io.papermc.paper.plugin.provider.source.DirectoryProviderSource.registerProviders(DirectoryProviderSource.java:14) ~[paper-1.20.1.jar:git-Paper-115]
        at io.papermc.paper.plugin.util.EntrypointUtil.registerProvidersFromSource(EntrypointUtil.java:14) ~[paper-1.20.1.jar:git-Paper-115]
        at io.papermc.paper.plugin.PluginInitializerManager.load(PluginInitializerManager.java:100) ~[paper-1.20.1.jar:git-Paper-115]
        at net.minecraft.server.Main.main(Main.java:126) ~[paper-1.20.1.jar:git-Paper-115]
        at org.bukkit.craftbukkit.Main.main(Main.java:316) ~[paper-1.20.1.jar:git-Paper-115]
        at io.papermc.paperclip.Paperclip.lambda$main$0(Paperclip.java:42) ~[app:?]
        at java.lang.Thread.run(Thread.java:1583) ~[?:?]
Caused by: java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
        at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVerifier.java:340) ~[?:?]
        at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier.java:282) ~[?:?]
        at java.util.jar.JarVerifier.processEntry(JarVerifier.java:320) ~[?:?]
        at java.util.jar.JarVerifier.update(JarVerifier.java:232) ~[?:?]
        at java.util.jar.JarFile.initializeVerifier(JarFile.java:760) ~[?:?]
        at java.util.jar.JarFile.getInputStream(JarFile.java:858) ~[?:?]
        at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProviderFactory.create(SpigotPluginProviderFactory.java:36) ~[paper-1.20.1.jar:git-Paper-115]
        at io.papermc.paper.plugin.provider.type.spigot.SpigotPluginProviderFactory.create(SpigotPluginProviderFactory.java:16) ~[paper-1.20.1.jar:git-Paper-115]
        at io.papermc.paper.plugin.provider.type.PluginFileType.getConfig(PluginFileType.java:77) ~[paper-1.20.1.jar:git-Paper-115]
        at io.papermc.paper.plugin.provider.type.PluginFileType.register(PluginFileType.java:70) ~[paper-1.20.1.jar:git-Paper-115]
        at io.papermc.paper.plugin.provider.source.FileProviderSource.registerProviders(FileProviderSource.java:57) ~[paper-1.20.1.jar:git-Paper-115]
        ... 20 more