Class ModInfoProvider

java.lang.Object
com.thecsdev.commonmc.api.util.modinfo.ModInfoProvider
Direct Known Subclasses:
FabricModInfoProvider, NeoForgeModInfoProvider

public abstract class ModInfoProvider extends Object
Provides information about currently installed mods.
  • Constructor Details

    • ModInfoProvider

      public ModInfoProvider()
  • Method Details

    • getInstance

      public static final ModInfoProvider getInstance()
      Returns the current ModInfoProvider instance, or null if none is present at the moment.
    • setInstance

      public static final void setInstance(@NotNull @NotNull ModInfoProvider provider) throws NullPointerException
      Sets the current ModInfoProvider instance.
      Parameters:
      provider - The new provider to set.
      Throws:
      NullPointerException - When the argument is null.
    • getModInfo

      @NotNull public abstract @NotNull ModInfo getModInfo(@NotNull @NotNull String modid) throws NullPointerException, NoSuchElementException
      Returns the ModInfo object for a given currently installed mod, or null if no such mod is installed.
      Parameters:
      modid - The unique namespace/ID of the mod.
      Throws:
      NullPointerException - When the argument is null.
      NoSuchElementException - When no mod with the given ID/namespace is installed.
    • getLoadedModIDs

      @NotNull public abstract @NotNull String[] getLoadedModIDs()
      Returns an array of all currently installed mod IDs/namespaces.
    • isModLoaded

      public abstract boolean isModLoaded(@NotNull @NotNull String modid) throws NullPointerException
      Returns whether a mod with the given ID/namespace is currently installed.
      Parameters:
      modid - The unique namespace/ID of the mod.
      Throws:
      NullPointerException - When the argument is null.
    • getModpackID

      @NotNull public final @NotNull String getModpackID()
      Returns a unique ID for the current modpack installation, which is generated by hashing the list of currently installed mods and their versions.