Record Class AddonConfiguration

java.lang.Object
java.lang.Record
de.craftsblock.craftsnet.addon.meta.AddonConfiguration
Record Components:
path - The Path which contains the addon.
json - Json representation of the addon configuration.
classpath - Array of URLs representing the classpath of the addon.
dependencyLoaders - An array of dependency class loaders which are used to load classes from the dependencies.
services - Collection of RegisteredService instances associated with the addon.
addon - Reference to the actual Addon instance.
meta - Reference to the AddonMeta metadata of the addon.
All Implemented Interfaces:
Comparable<AddonConfiguration>

public record AddonConfiguration(Path path, de.craftsblock.craftscore.json.Json json, URL[] classpath, DependencyClassLoader[] dependencyLoaders, Collection<RegisteredService> services, AtomicReference<Addon> addon, AtomicReference<AddonMeta> meta, AtomicReference<AddonClassLoader> classLoader) extends Record implements Comparable<AddonConfiguration>
Represents the configuration details of an Addon, including its metadata, classpath, and dependencies.

This class serves as a container for storing and managing the runtime configuration of addons, ensuring proper dependency management and validation of addon metadata.

Since:
3.1.0-SNAPSHOT
  • Field Details

    • NAME_VALIDATOR

      public static final Pattern NAME_VALIDATOR
      Pattern for validating addon names.

      Addon names can only contain alphanumeric characters.

  • Constructor Details

  • Method Details

    • of

      public static AddonConfiguration of(Path path, de.craftsblock.craftscore.json.Json json, URL[] classpath, DependencyClassLoader[] dependencyLoaders, Collection<RegisteredService> services)
      Creates an AddonConfiguration instance from the provided params.
      Parameters:
      path - The Path which contains the addon.
      json - Json representation of the addon configuration.
      classpath - Array of URLs representing the classpath of the addon.
      dependencyLoaders - An array of dependency class loaders which are used to load classes from the dependencies.
      services - Collection of RegisteredService instances associated with the addon.
      Returns:
      A new instance of AddonConfiguration.
    • of

      public static List<AddonConfiguration> of(CraftsNet craftsNet, AddonLoader loader, Class<? extends Addon> addon)
      Creates a list of AddonConfiguration instances from the provided Addon class, including its dependencies.
      Parameters:
      craftsNet - The instance of CraftsNet loading the addon for.
      loader - The instance of AddonLoader which loads the addon.
      addon - The addon class for which the configuration should be created.
      Returns:
      A list of AddonConfiguration, including the configuration of the addon and its dependencies.
      Throws:
      IllegalStateException - If the provided addon class is not annotated with Meta.
    • compareTo

      public int compareTo(@NotNull @NotNull AddonConfiguration o)
      Compares this configuration to another based on their addon names.
      Specified by:
      compareTo in interface Comparable<AddonConfiguration>
      Parameters:
      o - The other AddonConfiguration.
      Returns:
      A negative integer, zero, or a positive integer as this configuration's name is lexicographically less than, equal to, or greater than the other configuration's name.
    • map

      public static void map(Class<? extends Addon> addon, String name)
      Maps an addon class to a custom name.
      Parameters:
      addon - The addon class.
      name - The name to associate with the addon class.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • path

      public Path path()
      Returns the value of the path record component.
      Returns:
      the value of the path record component
    • json

      public de.craftsblock.craftscore.json.Json json()
      Returns the value of the json record component.
      Returns:
      the value of the json record component
    • classpath

      public URL[] classpath()
      Returns the value of the classpath record component.
      Returns:
      the value of the classpath record component
    • dependencyLoaders

      public DependencyClassLoader[] dependencyLoaders()
      Returns the value of the dependencyLoaders record component.
      Returns:
      the value of the dependencyLoaders record component
    • services

      public Collection<RegisteredService> services()
      Returns the value of the services record component.
      Returns:
      the value of the services record component
    • addon

      public AtomicReference<Addon> addon()
      Returns the value of the addon record component.
      Returns:
      the value of the addon record component
    • meta

      public AtomicReference<AddonMeta> meta()
      Returns the value of the meta record component.
      Returns:
      the value of the meta record component
    • classLoader

      public AtomicReference<AddonClassLoader> classLoader()
      Returns the value of the classLoader record component.
      Returns:
      the value of the classLoader record component