aboutsummaryrefslogtreecommitdiff
path: root/runtime/src/main/java/me/shedaniel/rei/impl/common
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-08-27 05:26:06 +0800
committershedaniel <daniel@shedaniel.me>2021-08-27 05:26:31 +0800
commit113fe8f692f4f9bb113d28f6a1b3375bd8f0eec8 (patch)
treeda371c2c28ec95167aea4ebc91a6ff4a9f5f59b3 /runtime/src/main/java/me/shedaniel/rei/impl/common
parenta4776b33fd86731249cf9b02c2ea6fff1bce9350 (diff)
downloadRoughlyEnoughItems-113fe8f692f4f9bb113d28f6a1b3375bd8f0eec8.tar.gz
RoughlyEnoughItems-113fe8f692f4f9bb113d28f6a1b3375bd8f0eec8.tar.bz2
RoughlyEnoughItems-113fe8f692f4f9bb113d28f6a1b3375bd8f0eec8.zip
Add hints for if REI does not initialize properly
Diffstat (limited to 'runtime/src/main/java/me/shedaniel/rei/impl/common')
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/EntryComparatorRegistryImpl.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryRegistryImpl.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryTypeRegistryImpl.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/fluid/FluidSupportProviderImpl.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java21
5 files changed, 38 insertions, 7 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/EntryComparatorRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/EntryComparatorRegistryImpl.java
index 51d91cb14..38fe8e118 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/EntryComparatorRegistryImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/comparison/EntryComparatorRegistryImpl.java
@@ -26,6 +26,7 @@ package me.shedaniel.rei.impl.common.entry.comparison;
import me.shedaniel.rei.api.common.entry.comparison.ComparisonContext;
import me.shedaniel.rei.api.common.entry.comparison.EntryComparator;
import me.shedaniel.rei.api.common.entry.comparison.EntryComparatorRegistry;
+import me.shedaniel.rei.api.common.registry.ReloadStage;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.jetbrains.annotations.ApiStatus;
@@ -47,6 +48,11 @@ public abstract class EntryComparatorRegistryImpl<T, S> implements EntryComparat
}
@Override
+ public ReloadStage getStage() {
+ return ReloadStage.START;
+ }
+
+ @Override
public void startReload() {
comparators.clear();
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryRegistryImpl.java
index 07c0e618c..a52ee508a 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryRegistryImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryRegistryImpl.java
@@ -31,6 +31,7 @@ import me.shedaniel.rei.api.client.config.ConfigObject;
import me.shedaniel.rei.api.client.plugins.REIClientPlugin;
import me.shedaniel.rei.api.client.registry.entry.EntryRegistry;
import me.shedaniel.rei.api.common.entry.EntryStack;
+import me.shedaniel.rei.api.common.registry.ReloadStage;
import me.shedaniel.rei.api.common.util.CollectionUtils;
import me.shedaniel.rei.api.common.util.EntryStacks;
import me.shedaniel.rei.impl.client.config.ConfigObjectImpl;
@@ -69,6 +70,11 @@ public class EntryRegistryImpl implements EntryRegistry {
}
@Override
+ public ReloadStage getStage() {
+ return ReloadStage.START;
+ }
+
+ @Override
public void startReload() {
entries.clear();
if (reloadingRegistry != null) {
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryTypeRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryTypeRegistryImpl.java
index 43e3531ce..f25f2d13f 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryTypeRegistryImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/EntryTypeRegistryImpl.java
@@ -32,6 +32,7 @@ import me.shedaniel.rei.api.common.entry.type.EntryType;
import me.shedaniel.rei.api.common.entry.type.EntryTypeBridge;
import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry;
import me.shedaniel.rei.api.common.plugins.REIPlugin;
+import me.shedaniel.rei.api.common.registry.ReloadStage;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.ApiStatus;
@@ -46,6 +47,11 @@ public class EntryTypeRegistryImpl implements EntryTypeRegistry {
private final Table<ResourceLocation, ResourceLocation, List<EntryTypeBridge<?, ?>>> typeBridges = HashBasedTable.create();
@Override
+ public ReloadStage getStage() {
+ return ReloadStage.START;
+ }
+
+ @Override
public void acceptPlugin(REIPlugin<?> plugin) {
plugin.registerEntryTypes(this);
}
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/fluid/FluidSupportProviderImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/fluid/FluidSupportProviderImpl.java
index 00ae2d0c4..47d1f277c 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/common/fluid/FluidSupportProviderImpl.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/fluid/FluidSupportProviderImpl.java
@@ -30,6 +30,7 @@ import dev.architectury.fluid.FluidStack;
import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.fluid.FluidSupportProvider;
import me.shedaniel.rei.api.common.plugins.REIPlugin;
+import me.shedaniel.rei.api.common.registry.ReloadStage;
import net.minecraft.world.item.ItemStack;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Nullable;
@@ -46,6 +47,11 @@ public class FluidSupportProviderImpl extends ForwardingList<FluidSupportProvide
private final List<Provider> immutable = Collections.unmodifiableList(providers);
@Override
+ public ReloadStage getStage() {
+ return ReloadStage.START;
+ }
+
+ @Override
public void acceptPlugin(REIPlugin<?> plugin) {
plugin.registerFluidSupport(this);
}
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 0c43edeee..48e818d32 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
@@ -32,6 +32,7 @@ import me.shedaniel.rei.api.common.plugins.PluginManager;
import me.shedaniel.rei.api.common.plugins.PluginView;
import me.shedaniel.rei.api.common.plugins.REIPlugin;
import me.shedaniel.rei.api.common.plugins.REIPluginProvider;
+import me.shedaniel.rei.api.common.registry.ReloadStage;
import me.shedaniel.rei.api.common.registry.Reloadable;
import me.shedaniel.rei.api.common.util.CollectionUtils;
import net.minecraft.Util;
@@ -149,7 +150,7 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager<
}
@Override
- public void startReload() {
+ public void startReload(ReloadStage stage) {
try {
reloading = true;
long startTime = Util.getMillis();
@@ -158,7 +159,7 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager<
for (Reloadable<P> reloadable : reloadables) {
Class<?> reloadableClass = reloadable.getClass();
try (SectionClosable startReload = section(sectionData, "start-reload-" + MoreObjects.firstNonNull(reloadableClass.getSimpleName(), reloadableClass.getName()))) {
- reloadable.startReload();
+ reloadable.startReload(stage);
} catch (Throwable throwable) {
throwable.printStackTrace();
}
@@ -166,20 +167,26 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager<
List<P> plugins = new ArrayList<>(getPlugins().toList());
plugins.sort(Comparator.comparingDouble(P::getPriority).reversed());
- RoughlyEnoughItemsCore.LOGGER.info("Reloading Plugin Manager [%s], registered %d plugins: %s", pluginClass.getSimpleName(), plugins.size(), CollectionUtils.mapAndJoinToString(plugins, REIPlugin::getPluginProviderName, ", "));
+ 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);
- pluginSection(sectionData, "pre-register", plugins, REIPlugin::preRegister);
+ 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, reloadable::acceptPlugin);
+ 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);
}
- 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()))) {
- reloadable.endReload();
+ reloadable.endReload(stage);
} catch (Throwable throwable) {
throwable.printStackTrace();
}