aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/main/java/me/shedaniel/rei/impl/common
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-08-28 04:27:25 +0800
committershedaniel <daniel@shedaniel.me>2021-08-28 16:12:05 +0800
commit88472ebfdce663fb3cbc5448cfa1137358ed9b16 (patch)
tree1f0220f9df63c3cc4006320d4f1e73bedab8326b /runtime/src/main/java/me/shedaniel/rei/impl/common
parent8a0601c75fa2462494ed949797f04243fe9cb10e (diff)
downloadRoughlyEnoughItems-88472ebfdce663fb3cbc5448cfa1137358ed9b16.tar.gz
RoughlyEnoughItems-88472ebfdce663fb3cbc5448cfa1137358ed9b16.tar.bz2
RoughlyEnoughItems-88472ebfdce663fb3cbc5448cfa1137358ed9b16.zip
Fix #500
Diffstat (limited to 'runtime/src/main/java/me/shedaniel/rei/impl/common')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java26
1 files changed, 18 insertions, 8 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java
index 48e818d32..82bc8f518 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java
@@ -150,6 +150,24 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager<
}
@Override
+ public void pre() {
+ List<P> plugins = new ArrayList<>(getPlugins().toList());
+ plugins.sort(Comparator.comparingDouble(P::getPriority).reversed());
+ Collections.reverse(plugins);
+ MutablePair<Stopwatch, String> sectionData = new MutablePair<>(Stopwatch.createUnstarted(), "");
+ pluginSection(sectionData, "pre-register", plugins, REIPlugin::preRegister);
+ }
+
+ @Override
+ public void post() {
+ List<P> plugins = new ArrayList<>(getPlugins().toList());
+ plugins.sort(Comparator.comparingDouble(P::getPriority).reversed());
+ Collections.reverse(plugins);
+ MutablePair<Stopwatch, String> sectionData = new MutablePair<>(Stopwatch.createUnstarted(), "");
+ pluginSection(sectionData, "post-register", plugins, REIPlugin::postRegister);
+ }
+
+ @Override
public void startReload(ReloadStage stage) {
try {
reloading = true;
@@ -170,19 +188,11 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager<
RoughlyEnoughItemsCore.LOGGER.info("Reloading Plugin Manager [%s] stage [%s], registered %d plugins: %s", pluginClass.getSimpleName(), stage.toString(), plugins.size(), CollectionUtils.mapAndJoinToString(plugins, REIPlugin::getPluginProviderName, ", "));
Collections.reverse(plugins);
- if (stage == ReloadStage.START) {
- pluginSection(sectionData, "pre-register", plugins, REIPlugin::preRegister);
- }
-
for (Reloadable<P> reloadable : getReloadables()) {
Class<?> reloadableClass = reloadable.getClass();
pluginSection(sectionData, "reloadable-plugin-" + MoreObjects.firstNonNull(reloadableClass.getSimpleName(), reloadableClass.getName()), plugins, plugin -> reloadable.acceptPlugin(plugin, stage));
}
- if (stage == ReloadStage.END) {
- pluginSection(sectionData, "post-register", plugins, REIPlugin::postRegister);
- }
-
for (Reloadable<P> reloadable : reloadables) {
Class<?> reloadableClass = reloadable.getClass();
try (SectionClosable endReload = section(sectionData, "end-reload-" + MoreObjects.firstNonNull(reloadableClass.getSimpleName(), reloadableClass.getName()))) {