Class AllowedMods
java.lang.Object
com.craftingdead.protect.whitelist.AllowedMods
Loads and provides access to the allowed mods whitelist.
Supports both config-based override and built-in fallback.
-
Method Summary
Modifier and TypeMethodDescriptionstatic AllowedModsGets the singleton instance (uses cached instance if already initialized).static AllowedModsgetInstance(Path configDir) Gets the singleton instance with a specific config directory.getWhitelistedInfo(String modId) Gets whitelisted mod information by mod ID.intGets the number of whitelisted mods.booleanisLoaded()Checks if the whitelist was successfully loaded.booleanisModAllowed(String modId, String version, String hash) Checks if a mod is allowed based on its ID, version, and hash.booleanisModIdWhitelisted(String modId) Checks if a mod ID exists in the whitelist (regardless of version/hash).
-
Method Details
-
getInstance
Gets the singleton instance with a specific config directory.- Parameters:
configDir- The config directory path (e.g., FMLPaths.CONFIGDIR.get())
-
getInstance
Gets the singleton instance (uses cached instance if already initialized). -
getWhitelistedInfo
Gets whitelisted mod information by mod ID.- Parameters:
modId- The mod ID to look up- Returns:
- Optional containing the whitelist entry if found
-
isModAllowed
Checks if a mod is allowed based on its ID, version, and hash.- Parameters:
modId- Mod IDversion- Mod versionhash- 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
Checks if a mod ID exists in the whitelist (regardless of version/hash).
-