aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorshedaniel <daniel@shedaniel.me>2021-05-16 16:21:36 +0800
committershedaniel <daniel@shedaniel.me>2021-05-16 16:21:36 +0800
commit4e24411029bb5e21cbc91696503bab600cc7cd51 (patch)
treec00e3c0adad17cc883a077a6051c56cbd472be37
parent1c867f9d6e686c70c36b2f2b774fdee17211fa45 (diff)
downloadRoughlyEnoughItems-4e24411029bb5e21cbc91696503bab600cc7cd51.tar.gz
RoughlyEnoughItems-4e24411029bb5e21cbc91696503bab600cc7cd51.tar.bz2
RoughlyEnoughItems-4e24411029bb5e21cbc91696503bab600cc7cd51.zip
Refactor PluginManager
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java4
-rw-r--r--api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginManager.java6
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java2
-rw-r--r--runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java13
5 files changed, 12 insertions, 15 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java b/api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java
index e2e063023..8b2c8c0e1 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/display/DisplaySerializerRegistry.java
@@ -38,7 +38,7 @@ public interface DisplaySerializerRegistry extends Reloadable<REIPlugin<?>> {
* Registers a {@link DisplaySerializer} for serializing a {@link Display} for syncing across server-client, and
* for serializing displays to disk for favorites.
* <p>
- * Since REI 6, all {@link me.shedaniel.rei.api.client.registry.display.DisplayCategory}s are required to register their serializers,
+ * Since REI 6, all {@link me.shedaniel.rei.api.client.registry.display.DisplayCategory} are required to register their serializers,
* or mark themselves as unavailable for serialization.
*
* @param categoryId the category identifier of the display
@@ -51,7 +51,7 @@ public interface DisplaySerializerRegistry extends Reloadable<REIPlugin<?>> {
* Marks a {@link Display} as unavailable to sync across server-client, and
* for serializing displays to disk for favorites.
* <p>
- * Since REI 6, all {@link me.shedaniel.rei.api.client.registry.display.DisplayCategory}s are required to register their serializers,
+ * Since REI 6, all {@link me.shedaniel.rei.api.client.registry.display.DisplayCategory} are required to register their serializers,
* or mark themselves as unavailable for serialization.
*
* @param categoryId the category identifier of the display
diff --git a/api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginManager.java b/api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginManager.java
index 2a74d0493..7a525c045 100644
--- a/api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginManager.java
+++ b/api/src/main/java/me/shedaniel/rei/api/common/plugins/PluginManager.java
@@ -59,11 +59,11 @@ public interface PluginManager<P extends REIPlugin<?>> extends ParentReloadable<
() -> () -> Arrays.asList(getInstance(), getServerInstance()));
}
- static boolean areAnyPluginsReloading() {
- return CollectionUtils.anyMatch(getActiveInstances(), PluginManager::arePluginsReloading);
+ static boolean areAnyReloading() {
+ return CollectionUtils.anyMatch(getActiveInstances(), PluginManager::isReloading);
}
- boolean arePluginsReloading();
+ boolean isReloading();
<T extends Reloadable<? super P>> T get(Class<T> reloadableClass);
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java
index 94196c19e..cadbe569c 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ReloadPluginsEntry.java
@@ -49,7 +49,7 @@ public class ReloadPluginsEntry extends AbstractConfigListEntry<Unit> {
private AbstractWidget buttonWidget = new Button(0, 0, 0, 20, NarratorChatListener.NO_TITLE, button -> RoughlyEnoughItemsCore.reloadPlugins(null)) {
@Override
public void render(PoseStack matrices, int mouseX, int mouseY, float delta) {
- if (PluginManager.areAnyPluginsReloading()) {
+ if (PluginManager.areAnyReloading()) {
Screen screen = Minecraft.getInstance().screen;
Minecraft.getInstance().setScreen(new ConfigReloadingScreen(() -> Minecraft.getInstance().setScreen(screen)));
} else {
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java
index 17fede258..52a531acf 100644
--- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java
+++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/screen/ConfigReloadingScreen.java
@@ -48,7 +48,7 @@ public class ConfigReloadingScreen extends Screen {
@Override
public void render(PoseStack matrices, int int_1, int int_2, float float_1) {
this.renderDirtBackground(0);
- if (!PluginManager.areAnyPluginsReloading()) {
+ if (!PluginManager.areAnyReloading()) {
parent.run();
}
drawCenteredString(matrices, this.font, I18n.get("text.rei.config.is.reloading"), this.width / 2, this.height / 2 - 50, 16777215);
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 249abc0c6..684be988e 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
@@ -28,15 +28,12 @@ import com.google.common.base.Stopwatch;
import com.google.common.collect.FluentIterable;
import com.google.common.collect.Iterables;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
-import me.shedaniel.rei.api.client.registry.entry.EntryRegistry;
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.Reloadable;
import me.shedaniel.rei.api.common.util.CollectionUtils;
-import net.fabricmc.api.EnvType;
-import net.fabricmc.api.Environment;
import net.minecraft.Util;
import org.apache.commons.lang3.tuple.MutablePair;
import org.jetbrains.annotations.ApiStatus;
@@ -54,7 +51,7 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager<
private final Map<Class<? extends Reloadable<P>>, Reloadable<? super P>> cache = new ConcurrentHashMap<>();
private final Class<P> pluginClass;
private final UnaryOperator<PluginView<P>> view;
- private boolean arePluginsLoading = false;
+ private boolean reloading = false;
private final List<REIPluginProvider<P>> plugins = new ArrayList<>();
private final LongConsumer reloadDoneListener;
@@ -74,8 +71,8 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager<
}
@Override
- public boolean arePluginsReloading() {
- return arePluginsLoading;
+ public boolean isReloading() {
+ return reloading;
}
@Override
@@ -154,7 +151,7 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager<
@Override
public void startReload() {
try {
- arePluginsLoading = true;
+ reloading = true;
long startTime = Util.getMillis();
MutablePair<Stopwatch, String> sectionData = new MutablePair<>(Stopwatch.createUnstarted(), "");
@@ -193,7 +190,7 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager<
} catch (Throwable throwable) {
throwable.printStackTrace();
} finally {
- arePluginsLoading = false;
+ reloading = false;
}
}
}