blob: 80e1bafd97af3679c99e1f6f3b56ad4aa1818a5b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
package me.shedaniel.rei;
import info.tehnut.pluginloader.LoaderCreator;
import info.tehnut.pluginloader.PluginLoaderBuilder;
import info.tehnut.pluginloader.ValidationStrategy;
import me.shedaniel.rei.api.IRecipePlugin;
import net.fabricmc.loader.language.LanguageAdapter;
import net.fabricmc.loader.language.LanguageAdapterException;
import net.minecraft.util.Identifier;
public class RoughlyEnoughItemsPlugins implements LoaderCreator {
@Override
public void createLoaders() {
LanguageAdapter.Options instantiationOptions = new LanguageAdapter.Options();
new PluginLoaderBuilder("roughlyenoughitems")
.withValidator(ValidationStrategy.hasInterface(IRecipePlugin.class))
.withInitializer((aClass, container) -> {
Identifier id = new Identifier(container.getOwner().getInfo().getId(), container.getInfo().getId());
try {
IRecipePlugin plugin = (IRecipePlugin) container.getOwner().getAdapter().createInstance(aClass, instantiationOptions);
RoughlyEnoughItemsCore.registerPlugin(id, plugin);
} catch (LanguageAdapterException e) {
RoughlyEnoughItemsCore.LOGGER.error("REI: Error loading plugin %s", id, e);
}
})
.build();
}
}
|