Class ClassLoader

java.lang.Object
org.skriptlang.skript.util.ClassLoader

public class ClassLoader extends Object
A utility class for loading classes contained in specific packages.
  • Method Details

    • builder

      public static ClassLoader.Builder builder()
      Returns:
      A builder for creating a loader.
    • loadClasses

      public static void loadClasses(Class<?> source, File jarFile, String basePackage, String... subPackages)
      A utility method for loading and initializing all classes within the base package/subpackages. This method will perform a deep search, meaning classes within subpackages of subpackages will be initialized too.
      Parameters:
      source - A class within the resource classes should be loaded from.
      jarFile - A file representing the jar to search for classes.
      basePackage - The package within the jar to load classes from.
      subPackages - The specific subpackages within basePackage to load. If not provided, classes within basePackage and all of its subpackages will be loaded.
    • loadClasses

      public void loadClasses(Class<?> source)
      Loads all classes (from the provided source) meeting the criteria set by this loader. It is recommended to use one of the methods that also accept a [jar] file (loadClasses(Class, File) and loadClasses(Class, JarFile)) for increased reliability.
      Parameters:
      source - A class within the resource classes should be loaded from.
    • loadClasses

      public void loadClasses(Class<?> source, File jarFile)
      Loads all classes (from the provided source) meeting the criteria set by this loader.
      Parameters:
      source - A class within the resource classes should be loaded from.
      jarFile - A file representing the jar to search for classes. While it is possible to load the classes without a jar, it is recommended to provide one for reliability.
      See Also:
    • loadClasses

      public void loadClasses(Class<?> source, @Nullable @Nullable JarFile jar)
      Loads all classes (from the provided source) meeting the criteria set by this loader.
      Parameters:
      source - A class within the resource classes should be loaded from.
      jar - A jar to search for classes. While it is possible to load the classes without this jar, it is recommended to provide one for reliability.
      See Also: