Class ModuleApiLevels

java.lang.Object
com.ultikits.ultitools.manager.ModuleApiLevels

@Internal public final class ModuleApiLevels extends Object
Which module API levels /upm installs from a catalogue.

A module declares the UltiTools API level it is built for as the integer api-version of its plugin.yml. /upm installs, installs by version and stages updates only of modules at MIN_INSTALLABLE_API_LEVEL up to this framework's own level, and sends both numbers to the catalogue on every request so that the catalogue offers nothing else.

Why the floor exists. UltiTools-API 6.3.0 made UltiToolsPlugin.unregisterSelf() final, and every module built before 6.3.0 overrides it, so such a module fails to link (IncompatibleClassChangeError) at the next start. A catalogue that serves a pre-6.3.0 build -- one that does not filter by level, or a version recorded wrongly -- would otherwise be downloaded, reported installed and then refused at restart.

The module loader's admission rule is separate and unchanged: a JAR an operator places in the modules folder by hand is still judged by PluginManager's own rule. This class is an install policy of /upm, which only fetches from a catalogue.

The upper bound reuses PluginManager.requiresNewerFramework(int, int), the single definition of "the module needs a newer framework", so that comparison still exists once.

Since:
6.3.0
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final Logger
     
    static final int
    The lowest module api-version /upm installs: the first level built against the 6.3.0 module contract.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    This framework's own API level, as UltiTools.getPluginVersion() reads it from the bundled env.yml (630 for 6.3.0 and its snapshots).
    static boolean
    isInstallable(int moduleLevel, int floor, int frameworkLevel)
    Whether /upm installs a module declaring moduleLevel.
    static Integer
    parse(String declared)
    A plugin.yml api-version as an integer level.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • MIN_INSTALLABLE_API_LEVEL

      public static final int MIN_INSTALLABLE_API_LEVEL
      The lowest module api-version /upm installs: the first level built against the 6.3.0 module contract. Sent to the catalogue as minApiLevel, and used by the check of every downloaded JAR, so the catalogue never holds a second copy of this policy.
      See Also:
    • LOGGER

      private static final Logger LOGGER
  • Constructor Details

    • ModuleApiLevels

      private ModuleApiLevels()
  • Method Details

    • frameworkLevel

      public static int frameworkLevel()
      This framework's own API level, as UltiTools.getPluginVersion() reads it from the bundled env.yml (630 for 6.3.0 and its snapshots).

      When that cannot be read, or reads below MIN_INSTALLABLE_API_LEVEL -- impossible for a build that contains this class, so a misreading -- the floor is used instead and a warning is logged. The floor is a lower bound of the true level, so the fallback can only refuse a module this framework could load; it never admits one it cannot.

      Returns:
      the level to send as apiLevel and to check downloads against
    • isInstallable

      public static boolean isInstallable(int moduleLevel, int floor, int frameworkLevel)
      Whether /upm installs a module declaring moduleLevel.
      Parameters:
      moduleLevel - the module's declared api-version
      floor - the lowest level installed, MIN_INSTALLABLE_API_LEVEL
      frameworkLevel - this framework's level, frameworkLevel()
      Returns:
      true when floor <= moduleLevel <= frameworkLevel
    • parse

      public static Integer parse(String declared)
      A plugin.yml api-version as an integer level.
      Parameters:
      declared - the value as read, or null when the key is absent
      Returns:
      the level, or null when absent or not an integer (for example Bukkit's '1.19')