Package commoble.databuddy.plugin

# Class PluginLoader

java.lang.Object
commoble.databuddy.plugin.PluginLoader

public class PluginLoader extends Object
Helper for providing annotation apis to other mods and load and construct their classes

## Constructor Summary

Constructors
Constructor
Description
`PluginLoader()`

## Method Summary

Modifier and Type
Method
Description
`static <REGISTRATOR, PLUGIN extends Consumer<REGISTRATOR>, REGISTRY extends REGISTRATOR>
List<com.mojang.datafixers.util.Pair<String,Exception>>`
`loadPlugins(Class<?> annotationClass, Class<PLUGIN> pluginInterface, REGISTRY registrator)`
Gathers all classes that implement the given interface and are annotated with the given annotation, attempts to make one instance of each of these classes, and registers them to some plugin-registering object.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### PluginLoader

public PluginLoader()

## Method Details

### loadPlugins

public static <REGISTRATOR, PLUGIN extends Consumer<REGISTRATOR>, REGISTRY extends REGISTRATOR> List<com.mojang.datafixers.util.Pair<String,Exception>> loadPlugins(Class<?> annotationClass, Class<PLUGIN> pluginInterface, REGISTRY registrator)

Gathers all classes that implement the given interface and are annotated with the given annotation, attempts to make one instance of each of these classes, and registers them to some plugin-registering object.

In this manner, a mod that uses the plugin loader can grant API access to other mods if the API mod is present.

Classes that implement the given PLUGIN interface and are annotated with the given annotation must have an argless constructor, or that plugin will fail to load. Plugins that fail to load will be caught and logged.

Type Parameters:
  `REGISTRATOR` - Interface that plugins can consume
  `PLUGIN` - Plugin interface type. Must be able to consume REGISTRATORS.
  `REGISTRY` - Implementation type of REGISTRATOR to register plugins to
Parameters:
  `annotationClass` - Annotation class that the class scanner will look for
  `pluginInterface` - Registrator-consuming interface class
  `registrator` - The object to give to plugins so they can register things to it
Returns:
  A list of failure results; each entry contains the class name of a plugin class that could not be instantiated, and an exception that occurred when trying to instantiate it