Class AllowedMods

java.lang.Object
com.craftingdead.protect.whitelist.AllowedMods

public final class AllowedMods extends Object
Loads and provides access to the allowed mods whitelist. Supports both config-based override and built-in fallback.
  • Method Details

    • getInstance

      public static AllowedMods getInstance(Path configDir)
      Gets the singleton instance with a specific config directory.
      Parameters:
      configDir - The config directory path (e.g., FMLPaths.CONFIGDIR.get())
    • getInstance

      public static AllowedMods getInstance()
      Gets the singleton instance (uses cached instance if already initialized).
    • getWhitelistedInfo

      public Optional<AllowedModEntry> getWhitelistedInfo(String modId)
      Gets whitelisted mod information by mod ID.
      Parameters:
      modId - The mod ID to look up
      Returns:
      Optional containing the whitelist entry if found
    • isModAllowed

      public boolean isModAllowed(String modId, String version, String hash)
      Checks if a mod is allowed based on its ID, version, and hash.
      Parameters:
      modId - Mod ID
      version - Mod version
      hash - SHA-256 hash of the mod JAR
      Returns:
      true if the mod is whitelisted and matches, false otherwise
    • isLoaded

      public boolean isLoaded()
      Checks if the whitelist was successfully loaded.
    • getWhitelistSize

      public int getWhitelistSize()
      Gets the number of whitelisted mods.
    • isModIdWhitelisted

      public boolean isModIdWhitelisted(String modId)
      Checks if a mod ID exists in the whitelist (regardless of version/hash).