Class PluginCodeSource

java.lang.Object
com.ultikits.ultitools.context.PluginCodeSource

@Internal public final class PluginCodeSource extends Object
The resolved JAR or class directory of a plugin. Internal to the framework; not a public API.
Since:
7.2.0
  • Field Details

    • CLASS_EXTENSION

      private static final String CLASS_EXTENSION
      See Also:
    • path

      private final Path path
    • directory

      private final boolean directory
  • Constructor Details

    • PluginCodeSource

      private PluginCodeSource(Path path, boolean directory)
  • Method Details

    • resolve

      @Nullable public static @Nullable PluginCodeSource resolve(Class<?> runtimeClass)
      Resolves the first located class in the plugin's runtime superclass chain, before the Paper API. A generated subclass with no location inherits its author's scan source.
      Parameters:
      runtimeClass - the plugin's runtime class
      Returns:
      the plugin's local JAR or directory, or null if no local source is available
    • fromPath

      @Nullable public static @Nullable PluginCodeSource fromPath(Path root)
      Resolves an explicit local scan root, without consulting a class loader.
    • path

      public Path path()
      Returns:
      the normalized location of this source
    • isDirectory

      public boolean isDirectory()
      Returns:
      whether this source is a compiled class directory rather than a JAR
    • classNames

      public List<String> classNames(String basePackage) throws IOException
      Lists binary class names in the package and its subpackages from this source alone. An empty package scans the whole source. Descriptors and entries under META-INF are excluded.
      Parameters:
      basePackage - a dotted package name or the empty string
      Returns:
      candidate class names in unspecified order, without loading the classes
      Throws:
      IOException - if the source cannot be read
    • defines

      public boolean defines(Class<?> candidate)
      Tests the candidate's defining location, without looking at its superclass chain.
      Parameters:
      candidate - the resolved class to check
      Returns:
      whether the class was defined in this source
    • directoryClassNames

      private List<String> directoryClassNames(String basePackage) throws IOException
      Throws:
      IOException
    • jarClassNames

      private List<String> jarClassNames(String basePackage) throws IOException
      Throws:
      IOException
    • localPath

      @Nullable private static @Nullable Path localPath(@Nullable @Nullable URL location)