diff options
| author | shedaniel <daniel@shedaniel.me> | 2023-02-18 19:34:57 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2023-02-18 19:34:57 +0800 |
| commit | e2e92c603d57432070e5ba3ab22aa9d17b7932eb (patch) | |
| tree | fffd5d086ff1f21d9fc7aebeafaef98923aa8ec4 | |
| parent | 9d67c9a9bd769f6e49f47f957d4c1082ff74c0e7 (diff) | |
| parent | 3e7d52770bb9357b0ca4e921512e71bb6e272dfc (diff) | |
| download | RoughlyEnoughItems-e2e92c603d57432070e5ba3ab22aa9d17b7932eb.tar.gz RoughlyEnoughItems-e2e92c603d57432070e5ba3ab22aa9d17b7932eb.tar.bz2 RoughlyEnoughItems-e2e92c603d57432070e5ba3ab22aa9d17b7932eb.zip | |
Merge remote-tracking branch 'origin/9.x-1.19' into 10.x-1.19.3
| -rw-r--r-- | runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java | 64 | ||||
| -rw-r--r-- | runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java | 82 |
2 files changed, 98 insertions, 48 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java index 9119764a0..1786bbaee 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/ConfigManagerImpl.java @@ -41,9 +41,10 @@ import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.JsonNull; import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.JsonObject; import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.JsonPrimitive; import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.api.DeserializationException; -import me.shedaniel.clothconfig2.api.*; -import me.shedaniel.clothconfig2.gui.AbstractConfigScreen; -import me.shedaniel.clothconfig2.gui.GlobalizedClothConfigScreen; +import me.shedaniel.clothconfig2.api.AbstractConfigListEntry; +import me.shedaniel.clothconfig2.api.ConfigEntryBuilder; +import me.shedaniel.clothconfig2.api.Modifier; +import me.shedaniel.clothconfig2.api.ModifierKeyCode; import me.shedaniel.clothconfig2.gui.entries.KeyCodeEntry; import me.shedaniel.clothconfig2.gui.entries.TextListEntry; import me.shedaniel.rei.api.client.REIRuntime; @@ -401,8 +402,6 @@ public class ConfigManagerImpl implements ConfigManager { provider.setOptionFunction((baseI13n, field) -> field.isAnnotationPresent(ConfigObjectImpl.DontApplyFieldName.class) ? baseI13n : String.format("%s.%s", baseI13n, field.getName())); provider.setCategoryFunction((baseI13n, categoryName) -> String.format("%s.%s", baseI13n, categoryName)); provider.setBuildFunction(builder -> { - builder.setGlobalized(true); - builder.setGlobalizedExpanded(false); if (Minecraft.getInstance().getConnection() != null && Minecraft.getInstance().getConnection().getRecipeManager() != null) { TextListEntry feedbackEntry = ConfigEntryBuilder.create().startTextDescription( Component.translatable("text.rei.feedback", Component.translatable("text.rei.feedback.link") @@ -418,36 +417,33 @@ public class ConfigManagerImpl implements ConfigManager { builder.getOrCreateCategory(Component.translatable("config.roughlyenoughitems.advanced")).getEntries().add(0, new ReloadPluginsEntry(220)); builder.getOrCreateCategory(Component.translatable("config.roughlyenoughitems.advanced")).getEntries().add(0, new PerformanceEntry(220)); } + ConfigAddonRegistryImpl addonRegistry = (ConfigAddonRegistryImpl) ConfigAddonRegistry.getInstance(); + if (!addonRegistry.getAddons().isEmpty()) { + builder.getOrCreateCategory(Component.translatable("config.roughlyenoughitems.basics")).getEntries().add(0, new EmptyEntry(4)); + builder.getOrCreateCategory(Component.translatable("config.roughlyenoughitems.basics")).getEntries().add(0, new ConfigAddonsEntry(220)); + } + TextListEntry supportText = ConfigEntryBuilder.create().startTextDescription( + Component.translatable("text.rei.support.me.desc", + Component.translatable("text.rei.support.me.patreon") + .withStyle(style -> style + .withColor(TextColor.fromRgb(0xff1fc3ff)) + .withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://patreon.com/shedaniel")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("https://patreon.com/shedaniel"))) + ), + Component.translatable("text.rei.support.me.bisect") + .withStyle(style -> style + .withColor(TextColor.fromRgb(0xff1fc3ff)) + .withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.bisecthosting.com/shedaniel")) + .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("https://www.bisecthosting.com/shedaniel"))) + ) + ) + .withStyle(ChatFormatting.GRAY) + ).build(); + builder.getOrCreateCategory(Component.translatable("config.roughlyenoughitems.basics")).getEntries().add(0, new EmptyEntry(4)); + builder.getOrCreateCategory(Component.translatable("config.roughlyenoughitems.basics")).getEntries().add(0, supportText); + builder.getOrCreateCategory(Component.translatable("config.roughlyenoughitems.basics")).getEntries().add(0, new TitleTextEntry(Component.translatable("text.rei.support.me"))); + builder.getOrCreateCategory(Component.translatable("config.roughlyenoughitems.basics")).getEntries().add(0, new EmptyEntry(4)); return builder.setAfterInitConsumer(screen -> { - ConfigAddonRegistryImpl addonRegistry = (ConfigAddonRegistryImpl) ConfigAddonRegistry.getInstance(); - if (!addonRegistry.getAddons().isEmpty()) { - ((GlobalizedClothConfigScreen) screen).listWidget.children().add(0, (AbstractConfigEntry) new EmptyEntry(4)); - ConfigAddonsEntry configAddonsEntry = new ConfigAddonsEntry(220); - configAddonsEntry.setScreen((AbstractConfigScreen) screen); - ((GlobalizedClothConfigScreen) screen).listWidget.children().add(0, (AbstractConfigEntry) configAddonsEntry); - } - ((GlobalizedClothConfigScreen) screen).listWidget.children().add(0, (AbstractConfigEntry) new EmptyEntry(4)); - TextListEntry supportText = ConfigEntryBuilder.create().startTextDescription( - Component.translatable("text.rei.support.me.desc", - Component.translatable("text.rei.support.me.patreon") - .withStyle(style -> style - .withColor(TextColor.fromRgb(0xff1fc3ff)) - .withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://patreon.com/shedaniel")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("https://patreon.com/shedaniel"))) - ), - Component.translatable("text.rei.support.me.bisect") - .withStyle(style -> style - .withColor(TextColor.fromRgb(0xff1fc3ff)) - .withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, "https://www.bisecthosting.com/shedaniel")) - .withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Component.literal("https://www.bisecthosting.com/shedaniel"))) - ) - ) - .withStyle(ChatFormatting.GRAY) - ).build(); - supportText.setScreen((AbstractConfigScreen) screen); - ((GlobalizedClothConfigScreen) screen).listWidget.children().add(0, (AbstractConfigEntry) supportText); - ((GlobalizedClothConfigScreen) screen).listWidget.children().add(0, (AbstractConfigEntry) new TitleTextEntry(Component.translatable("text.rei.support.me"))); - ((GlobalizedClothConfigScreen) screen).listWidget.children().add(0, (AbstractConfigEntry) new EmptyEntry(4)); ScreenHooks.addRenderableWidget(screen, new Button(screen.width - 104, 4, 100, 20, Component.translatable("text.rei.credits"), button -> { CreditsScreen creditsScreen = new CreditsScreen(screen); Minecraft.getInstance().setScreen(creditsScreen); 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 4cb4cf474..bd181824d 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 @@ -52,6 +52,7 @@ import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.util.function.BiConsumer; import java.util.function.UnaryOperator; +import java.util.stream.Stream; @ApiStatus.Internal public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager<P>, PluginView<P> { @@ -160,7 +161,7 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager< plugin -> new PluginWrapper(plugin, input)))); } - private static class SectionClosable implements Closeable { + private class SectionClosable implements Closeable { private ReloadStage stage; private MutablePair<Stopwatch, String> sectionData; @@ -168,7 +169,7 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager< this.stage = stage; this.sectionData = new MutablePair<>(Stopwatch.createUnstarted(), ""); sectionData.setRight(section); - InternalLogger.getInstance().trace("[" + stage + "] Reloading Section: \"%s\"", section); + InternalLogger.getInstance().trace("[" + name(pluginClass) + " " + stage + "] Reloading Section: \"%s\"", section); sectionData.getLeft().reset().start(); } @@ -176,7 +177,7 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager< public void close() { sectionData.getLeft().stop(); String section = sectionData.getRight(); - InternalLogger.getInstance().trace("[" + stage + "] Reloading Section: \"%s\" done in %s", section, sectionData.getLeft().toString()); + InternalLogger.getInstance().trace("[" + name(pluginClass) + " " + stage + "] Reloading Section: \"%s\" done in %s", section, sectionData.getLeft().toString()); sectionData.getLeft().reset(); } } @@ -230,14 +231,25 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager< @Override public void pre(ReloadStage stage) { + List<PluginWrapper<P>> plugins = new ArrayList<>(getPluginWrapped().toList()); + plugins.sort(Comparator.comparingDouble(PluginWrapper<P>::getPriority).reversed()); + Collections.reverse(plugins); + InternalLogger.getInstance().debug("========================================"); + InternalLogger.getInstance().debug(name(pluginClass) + " starting pre-reload for " + stage + "."); + InternalLogger.getInstance().debug("Reloadables (%d):".formatted(reloadables.size())); + for (Reloadable<P> reloadable : reloadables) { + InternalLogger.getInstance().debug(" - " + name(reloadable.getClass())); + } + InternalLogger.getInstance().debug("Plugins (%d):".formatted(plugins.size())); + for (PluginWrapper<P> plugin : plugins) { + InternalLogger.getInstance().debug(" - (%.2f) ".formatted(plugin.getPriority()) + plugin.getPluginProviderName()); + } + InternalLogger.getInstance().debug("========================================"); this.forcedMainThread = false; this.forceMainThreadStopwatch.reset(); this.reloadStopwatch.reset().start(); this.observedStages.clear(); this.observedStages.add(stage); - List<PluginWrapper<P>> plugins = new ArrayList<>(getPluginWrapped().toList()); - plugins.sort(Comparator.comparingDouble(PluginWrapper<P>::getPriority).reversed()); - Collections.reverse(plugins); try (SectionClosable preRegister = section(stage, "pre-register/"); PerformanceLogger.Plugin perfLogger = RoughlyEnoughItemsCore.PERFORMANCE_LOGGER.stage("Pre Registration")) { pluginSection(stage, "pre-register/", plugins, null, (plugin, sink) -> { @@ -251,14 +263,29 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager< new RuntimeException("Failed to run pre registration").printStackTrace(); } this.reloadStopwatch.stop(); + InternalLogger.getInstance().debug("========================================"); + InternalLogger.getInstance().debug(name(pluginClass) + " finished pre-reload for " + stage + " in " + reloadStopwatch + "."); + InternalLogger.getInstance().debug("========================================"); } @Override public void post(ReloadStage stage) { - this.reloadStopwatch.start(); List<PluginWrapper<P>> plugins = new ArrayList<>(getPluginWrapped().toList()); plugins.sort(Comparator.comparingDouble(PluginWrapper<P>::getPriority).reversed()); Collections.reverse(plugins); + InternalLogger.getInstance().debug("========================================"); + InternalLogger.getInstance().debug(name(pluginClass) + " starting post-reload for " + stage + "."); + InternalLogger.getInstance().debug("Reloadables (%d):".formatted(reloadables.size())); + for (Reloadable<P> reloadable : reloadables) { + InternalLogger.getInstance().debug(" - " + name(reloadable.getClass())); + } + InternalLogger.getInstance().debug("Plugins (%d):".formatted(plugins.size())); + for (PluginWrapper<P> plugin : plugins) { + InternalLogger.getInstance().debug(" - (%.2f) ".formatted(plugin.getPriority()) + plugin.getPluginProviderName()); + } + InternalLogger.getInstance().debug("========================================"); + this.reloadStopwatch.start(); + Stopwatch postStopwatch = Stopwatch.createStarted(); try (SectionClosable postRegister = section(stage, "post-register/"); PerformanceLogger.Plugin perfLogger = RoughlyEnoughItemsCore.PERFORMANCE_LOGGER.stage("Post Registration")) { pluginSection(stage, "post-register/", plugins, null, (plugin, sink) -> { @@ -272,10 +299,13 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager< new RuntimeException("Failed to run post registration").printStackTrace(); } this.reloadStopwatch.stop(); - InternalLogger.getInstance().info("Reloaded Plugin Manager [%s] with %d plugins in %s.", pluginClass.getSimpleName(), plugins.size(), reloadStopwatch); + postStopwatch.stop(); + InternalLogger.getInstance().debug("========================================"); + InternalLogger.getInstance().info(name(pluginClass) + " finished post-reload for " + stage + " in " + postStopwatch + ", totaling " + reloadStopwatch + "."); if (forcedMainThread) { InternalLogger.getInstance().warn("Forcing plugins to run on main thread took " + forceMainThreadStopwatch); } + InternalLogger.getInstance().debug("========================================"); } private static String name(Class<?> clazz) { @@ -288,9 +318,28 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager< public void startReload(ReloadStage stage) { try { this.reloadStopwatch.start(); + Stopwatch reloadingStopwatch = Stopwatch.createStarted(); reloading = stage; + + // Sort Plugins + List<PluginWrapper<P>> plugins = new ArrayList<>(getPluginWrapped().toList()); + plugins.sort(Comparator.comparingDouble(PluginWrapper<P>::getPriority).reversed()); + Collections.reverse(plugins); // Pre Reload + String line = new String[]{"*", "=", "#", "@", "%", "~", "O", "-", "+"}[new Random().nextInt(9)].repeat(40); + InternalLogger.getInstance().info(line); + InternalLogger.getInstance().info(name(pluginClass) + " starting main-reload for " + stage + "."); + InternalLogger.getInstance().debug("Reloadables (%d):".formatted(reloadables.size())); + for (Reloadable<P> reloadable : reloadables) { + InternalLogger.getInstance().debug(" - " + name(reloadable.getClass())); + } + InternalLogger.getInstance().info("Plugins (%d):".formatted(plugins.size())); + for (PluginWrapper<P> plugin : plugins) { + InternalLogger.getInstance().info(" - (%.2f) ".formatted(plugin.getPriority()) + plugin.getPluginProviderName()); + } + InternalLogger.getInstance().info(line); + try (SectionClosable startReloadAll = section(stage, "start-reload/"); PerformanceLogger.Plugin perfLogger = RoughlyEnoughItemsCore.PERFORMANCE_LOGGER.stage("Reload Initialization")) { for (Reloadable<P> reloadable : reloadables) { @@ -304,13 +353,11 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager< } } - // Sort Plugins - List<PluginWrapper<P>> plugins = new ArrayList<>(getPluginWrapped().toList()); - plugins.sort(Comparator.comparingDouble(PluginWrapper<P>::getPriority).reversed()); - InternalLogger.getInstance().info("Reloading Plugin Manager [%s] stage [%s], registered %d plugins: %s", name(pluginClass), stage.toString(), plugins.size(), CollectionUtils.mapAndJoinToString(plugins, PluginWrapper::getPluginProviderName, ", ")); - Collections.reverse(plugins); - // Reload + InternalLogger.getInstance().debug("========================================"); + InternalLogger.getInstance().debug(name(pluginClass) + " started main-reload for " + stage + "."); + InternalLogger.getInstance().debug("========================================"); + for (Reloadable<P> reloadable : getReloadables()) { Class<?> reloadableClass = reloadable.getClass(); try (SectionClosable reloadablePlugin = section(stage, "reloadable-plugin/" + name(reloadableClass) + "/"); @@ -364,6 +411,10 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager< } // Post Reload + InternalLogger.getInstance().debug("========================================"); + InternalLogger.getInstance().debug(name(pluginClass) + " ending main-reload for " + stage + "."); + InternalLogger.getInstance().debug("========================================"); + try (SectionClosable endReloadAll = section(stage, "end-reload/"); PerformanceLogger.Plugin perfLogger = RoughlyEnoughItemsCore.PERFORMANCE_LOGGER.stage("Reload Finalization")) { for (Reloadable<P> reloadable : reloadables) { @@ -378,6 +429,9 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager< } this.reloadStopwatch.stop(); + InternalLogger.getInstance().debug("========================================"); + InternalLogger.getInstance().debug(name(pluginClass) + " ended main-reload for " + stage + " in " + reloadingStopwatch.stop() + "."); + InternalLogger.getInstance().debug("========================================"); } catch (Throwable throwable) { throwable.printStackTrace(); } finally { |
