Class Plugins
java.lang.Object
com.xpdustry.claj.server.plugin.Plugins
- All Implemented Interfaces:
arc.ApplicationListener
Simplified
that only handles plugins.
invalid reference
mindustry.mod.Mods
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents a plugin's state.static final classstatic classstatic classPlugin metadata information.static classstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionfinal arc.util.CommandHandlerfinal arc.files.Fifinal arc.util.serialization.Jsonfinal PluginClassLoader -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcontextRun(Plugins.LoadedPlugin plugin, Runnable run) Inspect the current thread stack to find which plugin (based on its ClassLoader) is calling the method.voiddispose()voidIterates through each plugin with a main class.voideachEnabled(arc.func.Cons<Plugins.LoadedPlugin> cons) Iterates through each enabled plugin.findMeta(arc.files.Fi file) Tries to find the config file of a plugin.Same asgetConfig(Class)but tries to detect the plugin by the class calling this method.arc.files.FiSame asgetConfigFolder(Class)but tries to detect the plugin by the class calling this method.arc.files.FigetConfigFolder(Plugin plugin) arc.files.FigetConfigFolder(Class<? extends Plugin> plugin) arc.struct.Seq<String> getIncompatibility(arc.struct.Seq<String> out) Same asgetLogger(Plugin)but tries to detect the plugin by the class calling this method.Same asgetLogger(Plugin, Class)but tries to detect the plugin by the class calling this method.Same asgetLogger(Plugin, String)but tries to detect the plugin by the class calling this method.getMeta()Same asgetMeta(Class)but tries to detect the plugin by the class calling this method.arc.struct.Seq<String> voidinit()arc.struct.Seq<Plugins.LoadedPlugin> list()voidlistFiles(String directory, arc.func.Cons2<Plugins.LoadedPlugin, arc.files.Fi> cons) Returns a list of files per plugin subdirectory.voidload()Loads all plugins from the folder, but does not call any methods on them.locatePlugin(String name) arc.struct.Seq<Plugins.LoadedPlugin> arc.struct.OrderedMap<String, Plugins.PluginState> resolveDependencies(arc.struct.Seq<Plugins.PluginMeta> metas) Resolves the loading order of a list plugins using their internal names.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface arc.ApplicationListener
exit, fileDropped, pause, resize, resume, update
-
Field Details
-
directory
public final arc.files.Fi directory -
commands
public final arc.util.CommandHandler commands -
mainLoader
-
json
public final arc.util.serialization.Json json
-
-
Constructor Details
-
Plugins
public Plugins(arc.files.Fi directory, arc.util.CommandHandler commands)
-
-
Method Details
-
getConfigFolder
- Returns:
- the folder where configuration files for this plugin should go. Call this in init().
-
getConfigFolder
-
getConfig
- Returns:
- a settings handle of
'plugins/<plugin-name>/config.json'. Call this in init().
-
getConfig
- Returns:
- a settings handle of
'plugins/<plugin-name>/config.json'. Call this in init().
-
getMeta
- Returns:
- the plugin meta data. Call this in init().
-
getMeta
- Returns:
- the plugin meta. Call this in init().
-
getLogger
- Returns:
- a new main logger for the plugin.
-
getLogger
- Returns:
- a new main logger for the plugin.
-
getLogger
- Returns:
- a new logger for the plugin with the specified
topicClass.
-
getLogger
- Returns:
- a new logger for the plugin with the specified
topicClass.
-
getLogger
- Returns:
- a new logger for the plugin with the specified
topic.
-
getLogger
- Returns:
- a new logger for the plugin with the specified
topic.
-
getConfigFolder
public arc.files.Fi getConfigFolder()Same asgetConfigFolder(Class)but tries to detect the plugin by the class calling this method. -
getConfig
Same asgetConfig(Class)but tries to detect the plugin by the class calling this method. -
getMeta
Same asgetMeta(Class)but tries to detect the plugin by the class calling this method. -
getLogger
Same asgetLogger(Plugin)but tries to detect the plugin by the class calling this method. -
getLogger
Same asgetLogger(Plugin, Class)but tries to detect the plugin by the class calling this method. -
getLogger
Same asgetLogger(Plugin, String)but tries to detect the plugin by the class calling this method. -
detectCallingPlugin
-
listFiles
Returns a list of files per plugin subdirectory. -
getPlugin
- Returns:
- the loaded plugin found by name, or null if not found.
-
getPlugin
- Returns:
- the loaded plugin found by class, or null if not found.
-
init
public void init()- Specified by:
initin interfacearc.ApplicationListener
-
dispose
public void dispose()- Specified by:
disposein interfacearc.ApplicationListener
-
load
public void load()Loads all plugins from the folder, but does not call any methods on them. -
orderedPlugins
- Returns:
- plugins ordered in the correct way needed for dependencies.
-
locatePlugin
-
getPluginStrings
- Returns:
- a list of plugins and versions, in the format
name:version.
-
getIncompatibility
-
list
-
eachClass
Iterates through each plugin with a main class. -
eachEnabled
Iterates through each enabled plugin. -
contextRun
-
findMeta
Tries to find the config file of a plugin. -
resolveDependencies
public arc.struct.OrderedMap<String, Plugins.PluginState> resolveDependencies(arc.struct.Seq<Plugins.PluginMeta> metas) Resolves the loading order of a list plugins using their internal names.
-