Class ModUtils

Object
ModUtils

public class ModUtils extends Object
Contains methods for dealing with mod level (non-gameplay) tasks.
Since:
1.9b
Author:
LazyWizard
  • Method Details

    • isClassPresent

      public static boolean isClassPresent(String classCanonicalName)
      Checks if a class is present within the loaded mods.

      Note: this does not initialize the class if it is present.

      Parameters:
      classCanonicalName - The canonical name of the class to check for (ex: "data.scripts.plugins.ExamplePlugin").
      Returns:
      true if the class is present, false otherwise.
      Since:
      1.9b
    • loadClassesIfClassIsPresent

      public static boolean loadClassesIfClassIsPresent(String classCanonicalName, List<String> classesToLoadCanonicalNames, boolean initializeClasses) throws ClassNotFoundException
      Loads a List of classes if a specific class is present, optionally initializing them in the process.
      Parameters:
      classCanonicalName - The canonical name of the class to test for the presence of. If it is not present, no other classes will be loaded.
      classesToLoadCanonicalNames - The other classes to load if classCanonicalName is present.
      initializeClasses - Whether to initialize all newly loaded classes - used if they have static initializers you want to run.
      Returns:
      true if classCanonicalName was present and classesToLoadCanonicalNames were loaded, false otherwise.
      Throws:
      ClassNotFoundException - If any of the classes in classesToLoadCanonicalNames do not exist.
      Since:
      2.3
    • isModEnabled

      public static boolean isModEnabled(String modId)
      Check if a mod is enabled. Equivalent to ModManagerAPI.isModEnabled(String).
      Parameters:
      modId - The ID of the mod to check.
      Returns:
      true if the mod with ID modId is enabled, false otherwise.
      Since:
      2.3
    • getEnabledModIds

      public static List<String> getEnabledModIds()
      Returns the IDs of all currently enabled mods.
      Returns:
      A List containing the Ids of all enabled mods.
      Since:
      2.3
    • getOverrides

      public static List<String> getOverrides()
      Returns all vanilla files that have been explicitly overridden in a mod's mod_info.json.
      Returns:
      All vanilla files overridden by mods.
      Since:
      2.3