Package mindustry.mod
Class Mods
java.lang.Object
mindustry.mod.Mods
- All Implemented Interfaces:
arc.assets.Loadable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Represents a mod's state.static final class
static class
static class
Mod metadata information.static class
static enum
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a listener for parsed JSON objects.void
contextRun
(Mods.LoadedMod mod, Runnable run) void
Iterates through each mod with a main class.void
eachEnabled
(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.Fi
arc.files.Fi
getConfigFolder
(Mod mod) arc.struct.Seq<String>
getIncompatibility
(arc.struct.Seq<String> out) arc.struct.Seq<String>
void
handleContentError
(Content content, Throwable error) boolean
boolean
importMod
(arc.files.Fi file) Imports an external mod file.arc.struct.Seq<Mods.LoadedMod>
list()
void
listFiles
(String directory, arc.func.Cons2<Mods.LoadedMod, arc.files.Fi> cons) Returns a list of files per mod subdirectory.void
load()
Loads all mods from the folder, but does not call any methods on them.void
Repacks all in-game sprites.void
Creates all the content found in mod files.void
This must be run on the main thread!void
loadSync()
arc.struct.Seq<Mods.LoadedMod>
void
reload()
void
removeMod
(Mods.LoadedMod mod) Removes a mod file and marks it for requiring a restart.boolean
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.void
setEnabled
(Mods.LoadedMod mod, boolean enabled) Makes a mod enabled or disabled.boolean
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:
loadAsync
in interfacearc.assets.Loadable
-
loadSync
public void loadSync()- Specified by:
loadSync
in 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.
-