Package mindustry.mod
Class Mods
java.lang.Object
mindustry.mod.Mods
- All Implemented Interfaces:
arc.assets.Loadable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a mod's state.static final classstatic classstatic classMod metadata information.static classstatic enum -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds a listener for parsed JSON objects.voidcontextRun(Mods.LoadedMod mod, Runnable run) voidIterates through each mod with a main class.voideachEnabled(arc.func.Cons<Mods.LoadedMod> cons) Iterates through each enabled mod.findMeta(arc.files.Fi file) Tries to find the config file of a mod/plugin.arc.files.Fiarc.files.FigetConfigFolder(Mod mod) arc.struct.Seq<String>getIncompatibility(arc.struct.Seq<String> out) arc.struct.Seq<String>voidhandleContentError(Content content, Throwable error) booleanbooleanimportMod(arc.files.Fi file) Imports an external mod file.arc.struct.Seq<Mods.LoadedMod>list()voidlistFiles(String directory, arc.func.Cons2<Mods.LoadedMod, arc.files.Fi> cons) Returns a list of files per mod subdirectory.voidload()Loads all mods from the folder, but does not call any methods on them.voidRepacks all in-game sprites.voidCreates all the content found in mod files.voidThis must be run on the main thread!voidloadSync()arc.struct.Seq<Mods.LoadedMod>voidreload()voidremoveMod(Mods.LoadedMod mod) Removes a mod file and marks it for requiring a restart.booleanarc.struct.OrderedMap<String,Mods.ModState> resolveDependencies(arc.struct.Seq<Mods.ModMeta> metas) Resolves the loading order of a list mods/plugins using their internal names.voidsetEnabled(Mods.LoadedMod mod, boolean enabled) Makes a mod enabled or disabled.booleanMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface arc.assets.Loadable
getDependencies, getName
-
Constructor Details
-
Mods
public Mods()
-
-
Method Details
-
mainLoader
- Returns:
- the main class loader for all mods
-
getConfigFolder
- Returns:
- the folder where configuration files for this mod should go. Call this in init().
-
getConfig
- Returns:
- a file named 'config.json' in the config folder for the specified mod. Call this in init().
-
listFiles
Returns a list of files per mod subdirectory. -
getMod
- Returns:
- the loaded mod found by name, or null if not found.
-
getMod
- Returns:
- the loaded mod found by class, or null if not found.
-
importMod
Imports an external mod file. Folders are not supported here.- Throws:
IOException
-
loadAsync
public void loadAsync()Repacks all in-game sprites.- Specified by:
loadAsyncin interfacearc.assets.Loadable
-
loadSync
public void loadSync()- Specified by:
loadSyncin interfacearc.assets.Loadable
-
removeMod
Removes a mod file and marks it for requiring a restart. -
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
- Returns:
- mods ordered in the correct way needed for dependencies.
-
locateMod
-
reload
public void reload() -
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
-
addParseListener
Adds a listener for parsed JSON objects. -
getModStrings
- Returns:
- a list of mods and versions, in the format name:version.
-
setEnabled
Makes a mod enabled or disabled. shifts it. -
getIncompatibility
- 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
-
eachClass
Iterates through each mod with a main class. -
eachEnabled
Iterates through each enabled mod. -
contextRun
-
findMeta
Tries to find the config file of a mod/plugin. -
resolveDependencies
public arc.struct.OrderedMap<String,Mods.ModState> resolveDependencies(arc.struct.Seq<Mods.ModMeta> metas) Resolves the loading order of a list mods/plugins using their internal names.
-