Package mindustry.mod

Class Mods

java.lang.Object
mindustry.mod.Mods
All Implemented Interfaces:
Loadable

public class Mods extends Object implements Loadable
  • Constructor Details

    • Mods

      public Mods()
  • Method Details

    • mainLoader

      public ClassLoader mainLoader()
      Returns:
      the main class loader for all mods
    • getConfig

      public Fi getConfig(Mod mod)
      Returns a file named 'config.json' in a special folder for the specified plugin. Call this in init().
    • listFiles

      public void listFiles(String directory, Cons2<Mods.LoadedMod,Fi> cons)
      Returns a list of files per mod subdirectory.
    • getMod

      @Nullable public Mods.LoadedMod getMod(String name)
      Returns:
      the loaded mod found by name, or null if not found.
    • getMod

      @Nullable public Mods.LoadedMod getMod(Class<? extends Mod> type)
      Returns:
      the loaded mod found by class, or null if not found.
    • importMod

      public Mods.LoadedMod importMod(Fi file) throws IOException
      Imports an external mod file. Folders are not supported here.
      Throws:
      IOException
    • loadAsync

      public void loadAsync()
      Repacks all in-game sprites.
      Specified by:
      loadAsync in interface Loadable
    • loadSync

      public void loadSync()
      Specified by:
      loadSync in interface Loadable
    • removeMod

      public void removeMod(Mods.LoadedMod mod)
      Removes a mod file and marks it for requiring a restart.
    • getScripts

      public Scripts getScripts()
    • hasScripts

      public boolean hasScripts()
      Returns:
      whether the scripting engine has been initialized.
    • requiresReload

      public boolean requiresReload()
    • skipModLoading

      public boolean skipModLoading()
      Returns:
      whether to skip mod loading due to previous initialization failure.
    • load

      public void load()
      Loads all mods from the folder, but does not call any methods on them.
    • orderedMods

      public Seq<Mods.LoadedMod> orderedMods()
      Returns:
      mods ordered in the correct way needed for dependencies.
    • locateMod

      public Mods.LoadedMod locateMod(String name)
    • hasContentErrors

      public boolean hasContentErrors()
    • loadScripts

      public void loadScripts()
      This must be run on the main thread!
    • loadContent

      public void loadContent()
      Creates all the content found in mod files.
    • handleContentError

      public void handleContentError(Content content, Throwable error)
    • addParseListener

      public void addParseListener(ContentParser.ParseListener hook)
      Adds a listener for parsed JSON objects.
    • getModStrings

      public Seq<String> getModStrings()
      Returns:
      a list of mods and versions, in the format name:version.
    • setEnabled

      public void setEnabled(Mods.LoadedMod mod, boolean enabled)
      Makes a mod enabled or disabled. shifts it.
    • getIncompatibility

      public Seq<String> getIncompatibility(Seq<String> out)
      Returns:
      the mods that the client is missing. The inputted array is changed to contain the extra mods that the client has but the server doesn't.
    • list

      public Seq<Mods.LoadedMod> list()
    • eachClass

      public void eachClass(Cons<Mod> cons)
      Iterates through each mod with a main class.
    • eachEnabled

      public void eachEnabled(Cons<Mods.LoadedMod> cons)
      Iterates through each enabled mod.
    • contextRun

      public void contextRun(Mods.LoadedMod mod, Runnable run)
    • findMeta

      @Nullable public Mods.ModMeta findMeta(Fi file)
      Tries to find the config file of a mod/plugin.
    • resolveDependencies

      public OrderedMap<String,Mods.ModState> resolveDependencies(Seq<Mods.ModMeta> metas)
      Resolves the loading order of a list mods/plugins using their internal names.