Create and use a library

Discussion in 'Plugin Development' started by Sharpadogge, Jun 8, 2021 at 11:07 AM.

  1. Offline


    Hello, I have a question...

    I just want to know briefly how I develop a library for my plugins. I looked at this tutorial for that:

    I have created a project for myself, as in the tutorial and included practically exactly the same functions. Then I added a new dependency in Maven.

    I can compile my plugin without getting errors and auto-complete works as well (JetBrains IntelliJ is used). However, when I start my test server, I get the following error:

    java.lang.NoClassDefFoundError: de/sharpadogge/lib/TestLibrary
        at de.sharpadogge.plugin.Plugin.onEnable( ~[?:?]
    The line of code that causes this error message is this (the same as in the tutorial):

    // in onEnable()
    Now my question is how I can use this external library. Does the test-library.jar need to be in a specific folder? Or do I have to change something in my IntelliJ settings? Or in my pom.xml? I have absolutely no idea.

    Thanks for reading through my problem description, and thanks in advance for the help.
  2. Offline


    In a nutshell, if you want to use an external library, it's either have to be shaded in (with Maven's shade plugin or Gradle's shadow) or it has to be a separate plugin.
    What you can do is make the library as usual, but add a plugin.yml and a main class for Bukkit to load, or shade the entire library in your projects that use it.
    davidclue likes this.

Share This Page