java.lang.Object
io.papermc.paper.plugin.loader.library.impl.JarLibrary
All Implemented Interfaces:
ClassPathLibrary

@NullMarked public class JarLibrary extends Object implements ClassPathLibrary
A simple jar library implementation of the ClassPathLibrary that allows PluginLoaders to append a jar stored on the local file system into their runtime classloader.

An example creation of the jar library type may look like this:


   final JarLibrary customLibrary = new JarLibrary(Path.of("libs/custom-library-1.24.jar"));
 
resulting in a jar library that provides the jar at libs/custom-library-1.24.jar to the plugins classloader at runtime.

The jar library implementation will error if the file does not exist at the specified path.

  • Constructor Details

    • JarLibrary

      public JarLibrary(Path path)
      Creates a new jar library that references the jar file found at the provided path.
      Parameters:
      path - the path, relative to the JVMs start directory.
  • Method Details

    • register

      public void register(LibraryStore store) throws LibraryLoadingException
      Description copied from interface: ClassPathLibrary
      Called to register the library this class path library represents into the passed library store. This method may either be implemented by the plugins themselves if they need complex logic, or existing API exposed implementations of this interface may be used.
      Specified by:
      register in interface ClassPathLibrary
      Parameters:
      store - the library store instance to register this library into
      Throws:
      LibraryLoadingException - if library loading failed for this classpath library