From 8c8b7236f89c2fc2fbd7f2c52800d8933b4cca5e Mon Sep 17 00:00:00 2001 From: shedaniel Date: Wed, 27 Jul 2022 01:31:56 +0800 Subject: Add many more logging --- .../me/shedaniel/rei/RoughlyEnoughItemsCore.java | 23 +--- .../rei/RoughlyEnoughItemsCoreClient.java | 27 +--- .../rei/impl/client/config/ConfigManagerImpl.java | 4 +- .../config/addon/ConfigAddonRegistryImpl.java | 7 + .../favorites/FavoriteEntryTypeRegistryImpl.java | 5 + .../client/gui/widget/CachedEntryListRender.java | 6 +- .../widget/entrylist/EntryListSearchManager.java | 7 +- .../registry/category/CategoryRegistryImpl.java | 17 ++- .../registry/display/DisplayRegistryImpl.java | 17 ++- .../client/registry/screen/ExclusionZonesImpl.java | 5 +- .../client/registry/screen/ScreenRegistryImpl.java | 19 ++- .../rei/impl/client/search/SearchProviderImpl.java | 2 + .../search/method/InputMethodRegistryImpl.java | 5 + .../transfer/TransferHandlerRegistryImpl.java | 7 + .../shedaniel/rei/impl/client/view/ViewsImpl.java | 16 +-- .../impl/common/entry/type/EntryRegistryImpl.java | 2 + .../common/entry/type/PreFilteredEntryList.java | 8 +- .../collapsed/CollapsibleEntryRegistryImpl.java | 10 ++ .../rei/impl/common/plugins/PluginManagerImpl.java | 23 ++-- .../runtime/FilteredStacksVisibilityHandler.java | 4 +- .../assets/roughlyenoughitems/lang/vi_vn.json | 146 +++++++++++++++++++++ .../roughlyenoughitems/textures/gui/bopomofo.png | Bin 0 -> 175 bytes .../roughlyenoughitems/textures/gui/jyutping.png | Bin 0 -> 170 bytes .../roughlyenoughitems/textures/gui/pinyin.png | Bin 0 -> 180 bytes 24 files changed, 267 insertions(+), 93 deletions(-) create mode 100644 runtime/src/main/resources/assets/roughlyenoughitems/lang/vi_vn.json create mode 100644 runtime/src/main/resources/assets/roughlyenoughitems/textures/gui/bopomofo.png create mode 100644 runtime/src/main/resources/assets/roughlyenoughitems/textures/gui/jyutping.png create mode 100644 runtime/src/main/resources/assets/roughlyenoughitems/textures/gui/pinyin.png (limited to 'runtime') diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java index 8546ddb3e..5555acda0 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCore.java @@ -29,11 +29,7 @@ import dev.architectury.registry.ReloadListenerRegistry; import dev.architectury.utils.Env; import dev.architectury.utils.EnvExecutor; import me.shedaniel.cloth.clothconfig.shadowed.blue.endless.jankson.annotation.Nullable; -import me.shedaniel.rei.api.common.entry.comparison.FluidComparatorRegistry; -import me.shedaniel.rei.api.common.entry.comparison.ItemComparatorRegistry; import me.shedaniel.rei.api.common.entry.type.EntryType; -import me.shedaniel.rei.api.common.entry.type.EntryTypeRegistry; -import me.shedaniel.rei.api.common.fluid.FluidSupportProvider; import me.shedaniel.rei.api.common.plugins.PluginManager; import me.shedaniel.rei.api.common.plugins.PluginView; import me.shedaniel.rei.api.common.plugins.REIPlugin; @@ -88,6 +84,7 @@ public class RoughlyEnoughItemsCore { } public static void attachCommonInternals() { + Internals.attachInstanceSupplier(LOGGER, "logger"); CategoryIdentifierImpl.attach(); Internals.attachInstance((Function>) DeferringEntryTypeProviderImpl.INSTANCE, "entryTypeDeferred"); Internals.attachInstance(EntryStackProviderImpl.INSTANCE, Internals.EntryStackProvider.class); @@ -96,16 +93,6 @@ public class RoughlyEnoughItemsCore { Internals.attachInstanceSupplier(new PluginManagerImpl<>( REIPlugin.class, UnaryOperator.identity(), - usedTime -> { - RoughlyEnoughItemsCore.LOGGER.info("Reloaded Plugin Manager [%s] with %d entry types, %d item comparators, %d fluid comparators and %d fluid support providers in %dms.", - REIPlugin.class.getSimpleName(), - EntryTypeRegistry.getInstance().values().size(), - ItemComparatorRegistry.getInstance().comparatorSize(), - FluidComparatorRegistry.getInstance().comparatorSize(), - FluidSupportProvider.getInstance().size(), - usedTime - ); - }, new EntryTypeRegistryImpl(), new EntrySettingsAdapterRegistryImpl(), new RecipeManagerContextImpl<>(RecipeManagerContextImpl.supplier()), @@ -116,15 +103,7 @@ public class RoughlyEnoughItemsCore { Internals.attachInstanceSupplier(new PluginManagerImpl<>( REIServerPlugin.class, view -> view.then(PluginView.getInstance()), - usedTime -> { - RoughlyEnoughItemsCore.LOGGER.info("Reloaded Plugin Manager [%s] with %d menu infos in %dms.", - REIServerPlugin.class.getSimpleName(), - MenuInfoRegistry.getInstance().infoSize(), - usedTime - ); - }, new MenuInfoRegistryImpl()), "serverPluginManager"); - Internals.attachInstanceSupplier(LOGGER, "logger"); } public static void _reloadPlugins(@Nullable ReloadStage stage) { diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java index 647494f3b..923fc7383 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java @@ -44,9 +44,6 @@ import me.shedaniel.rei.api.client.gui.widgets.TooltipContext; import me.shedaniel.rei.api.client.overlay.ScreenOverlay; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; -import me.shedaniel.rei.api.client.registry.display.DisplayCategory; -import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; -import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; import me.shedaniel.rei.api.client.registry.screen.ClickArea; import me.shedaniel.rei.api.client.registry.screen.OverlayDecider; import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry; @@ -78,6 +75,7 @@ import me.shedaniel.rei.impl.client.search.method.InputMethodRegistryImpl; import me.shedaniel.rei.impl.client.subsets.SubsetsRegistryImpl; import me.shedaniel.rei.impl.client.transfer.TransferHandlerRegistryImpl; import me.shedaniel.rei.impl.client.view.ViewsImpl; +import me.shedaniel.rei.impl.common.InternalLogger; import me.shedaniel.rei.impl.common.entry.type.EntryRegistryImpl; import me.shedaniel.rei.impl.common.entry.type.collapsed.CollapsibleEntryRegistryImpl; import me.shedaniel.rei.impl.common.entry.type.types.EmptyEntryDefinition; @@ -120,7 +118,6 @@ import java.util.function.BiFunction; import java.util.function.BooleanSupplier; import java.util.function.Function; import java.util.function.Supplier; -import java.util.stream.Collectors; import java.util.stream.Stream; @Environment(EnvType.CLIENT) @@ -131,7 +128,7 @@ public class RoughlyEnoughItemsCoreClient { Thread thread = new Thread(task, "REI-ReloadPlugins"); thread.setDaemon(true); thread.setUncaughtExceptionHandler(($, exception) -> { - RoughlyEnoughItemsCore.LOGGER.throwException(exception); + InternalLogger.getInstance().throwException(exception); }); return thread; }); @@ -210,22 +207,6 @@ public class RoughlyEnoughItemsCoreClient { ClientInternals.attachInstanceSupplier(new PluginManagerImpl<>( REIClientPlugin.class, view -> view.then(PluginView.getInstance()), - usedTime -> { - RoughlyEnoughItemsCore.LOGGER.info("Reloaded Plugin Manager [%s] with %d entries, %d displays, %d display visibility predicates, %d categories (%s), %d exclusion zones and %d overlay deciders in %dms.", - REIClientPlugin.class.getSimpleName(), - EntryRegistry.getInstance().size(), - DisplayRegistry.getInstance().displaySize(), - DisplayRegistry.getInstance().getVisibilityPredicates().size(), - CategoryRegistry.getInstance().size(), - CategoryRegistry.getInstance().stream() - .map(CategoryRegistry.CategoryConfiguration::getCategory) - .map(DisplayCategory::getTitle) - .map(Component::getString).collect(Collectors.joining(", ")), - ScreenRegistry.getInstance().exclusionZones().getZonesCount(), - ScreenRegistry.getInstance().getDeciders().size(), - usedTime - ); - }, new EntryRendererRegistryImpl(), new ViewsImpl(), new InputMethodRegistryImpl(), @@ -341,7 +322,7 @@ public class RoughlyEnoughItemsCoreClient { } } - RoughlyEnoughItemsCore.LOGGER.error("Detected missing stage: END! This is possibly due to issues during client recipe reload! REI will force a reload of the recipes now!"); + InternalLogger.getInstance().error("Detected missing stage: END! This is possibly due to issues during client recipe reload! REI will force a reload of the recipes now!"); reloadPlugins(endReload, ReloadStage.END); } @@ -474,7 +455,7 @@ public class RoughlyEnoughItemsCoreClient { public static void reloadPlugins(MutableLong lastReload, @Nullable ReloadStage start) { if (lastReload != null) { if (lastReload.getValue() > 0 && System.currentTimeMillis() - lastReload.getValue() <= 5000) { - RoughlyEnoughItemsCore.LOGGER.warn("Suppressing Reload Plugins of stage " + start); + InternalLogger.getInstance().warn("Suppressing Reload Plugins of stage " + start); return; } lastReload.setValue(System.currentTimeMillis()); 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 6649506e4..583958a59 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 @@ -68,6 +68,7 @@ import me.shedaniel.rei.impl.client.entry.filtering.rules.ManualFilteringRule; import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl; import me.shedaniel.rei.impl.client.gui.credits.CreditsScreen; import me.shedaniel.rei.impl.client.gui.performance.entry.PerformanceEntry; +import me.shedaniel.rei.impl.common.InternalLogger; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.ChatFormatting; @@ -133,7 +134,7 @@ public class ConfigManagerImpl implements ConfigManager { } , (field) -> field.getType() == List.class, ConfigObjectImpl.UseFilteringScreen.class); saveConfig(); - RoughlyEnoughItemsCore.LOGGER.info("Config loaded."); + InternalLogger.getInstance().info("Config loaded"); } private static Jankson buildJankson(Jankson.Builder builder) { @@ -300,6 +301,7 @@ public class ConfigManagerImpl implements ConfigManager { return InteractionResult.PASS; }); AutoConfig.getConfigHolder(ConfigObjectImpl.class).save(); + InternalLogger.getInstance().debug("Config saved"); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonRegistryImpl.java index 859c6a867..6124cb83c 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonRegistryImpl.java @@ -26,6 +26,7 @@ package me.shedaniel.rei.impl.client.config.addon; import me.shedaniel.rei.api.client.config.addon.ConfigAddon; import me.shedaniel.rei.api.client.config.addon.ConfigAddonRegistry; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; +import me.shedaniel.rei.impl.common.InternalLogger; import java.util.ArrayList; import java.util.List; @@ -38,9 +39,15 @@ public class ConfigAddonRegistryImpl implements ConfigAddonRegistry { this.addons.clear(); } + @Override + public void endReload() { + InternalLogger.getInstance().debug("Registered %d config addons", this.addons.size()); + } + @Override public void register(ConfigAddon addon) { this.addons.add(addon); + InternalLogger.getInstance().debug("Added config addon: %s [%s]", addon, addon.getName().getString()); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/favorites/FavoriteEntryTypeRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/favorites/FavoriteEntryTypeRegistryImpl.java index 47996d9d3..fbd5f3330 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/favorites/FavoriteEntryTypeRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/favorites/FavoriteEntryTypeRegistryImpl.java @@ -36,6 +36,7 @@ import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.common.registry.ReloadStage; import me.shedaniel.rei.api.common.util.CollectionUtils; import me.shedaniel.rei.impl.client.config.ConfigManagerImpl; +import me.shedaniel.rei.impl.common.InternalLogger; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; import org.apache.commons.lang3.mutable.MutableLong; @@ -67,6 +68,7 @@ public class FavoriteEntryTypeRegistryImpl implements FavoriteEntryType.Registry @Override public void register(ResourceLocation id, FavoriteEntryType type) { this.registry.put(id, type); + InternalLogger.getInstance().debug("Added favorite entry type [%s]: %s", id, type); } @Override @@ -97,6 +99,7 @@ public class FavoriteEntryTypeRegistryImpl implements FavoriteEntryType.Registry @Override public void registerSystemFavorites(SystemFavoriteEntryProvider provider) { this.systemFavorites.add(Triple.of(provider, new MutableLong(-1), new ArrayList<>())); + InternalLogger.getInstance().debug("Added system favorites: %s", provider); } public List, MutableLong, List>> getSystemProviders() { @@ -119,6 +122,8 @@ public class FavoriteEntryTypeRegistryImpl implements FavoriteEntryType.Registry ConfigManager.getInstance().saveConfig(); } + + InternalLogger.getInstance().debug("Registered %d favorite entry types", registry.size()); } private static class SectionImpl implements FavoriteEntryType.Section { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java index 905aba9b2..60c7b98ce 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/CachedEntryListRender.java @@ -36,13 +36,13 @@ import it.unimi.dsi.fastutil.longs.Long2LongMap; import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap; import me.shedaniel.clothconfig2.api.LazyResettable; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.entry.renderer.EntryRenderer; import me.shedaniel.rei.api.client.registry.entry.EntryRegistry; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; import me.shedaniel.rei.api.common.util.EntryStacks; +import me.shedaniel.rei.impl.common.InternalLogger; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.GameRenderer; import net.minecraft.client.renderer.RenderStateShard; @@ -88,7 +88,7 @@ public class CachedEntryListRender { public static void refresh() { if (ConfigObject.getInstance().doesCacheEntryRendering()) { - RoughlyEnoughItemsCore.LOGGER.info("Refreshing cached entry list texture..."); + InternalLogger.getInstance().info("Refreshing cached entry list texture..."); } if (cachedTextureLocation != null) { Minecraft.getInstance().getTextureManager().release(cachedTextureLocation); @@ -139,7 +139,7 @@ public class CachedEntryListRender { int width = side * RESOLUTION; int height = side * RESOLUTION; - RoughlyEnoughItemsCore.LOGGER.info("Preparing cached texture with size %sx%s for %sx%s entries", width, height, side, side); + InternalLogger.getInstance().info("Preparing cached texture with size %sx%s for %sx%s entries", width, height, side, side); hash = new Long2LongOpenHashMap(list.size() + 10); Minecraft minecraft = Minecraft.getInstance(); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListSearchManager.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListSearchManager.java index 2aee122fe..a03865208 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListSearchManager.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/gui/widget/entrylist/EntryListSearchManager.java @@ -26,7 +26,6 @@ package me.shedaniel.rei.impl.client.gui.widget.entrylist; import com.google.common.base.Stopwatch; import it.unimi.dsi.fastutil.longs.LongOpenHashSet; import it.unimi.dsi.fastutil.longs.LongSet; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.client.config.ConfigManager; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.gui.config.EntryPanelOrdering; @@ -37,11 +36,13 @@ import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; import me.shedaniel.rei.api.common.util.EntryStacks; import me.shedaniel.rei.impl.client.search.AsyncSearchManager; +import me.shedaniel.rei.impl.common.InternalLogger; import me.shedaniel.rei.impl.common.entry.type.collapsed.CollapsedStack; import me.shedaniel.rei.impl.common.entry.type.collapsed.CollapsibleEntryRegistryImpl; import net.minecraft.client.Minecraft; import net.minecraft.world.item.CreativeModeTab; import net.minecraft.world.item.ItemStack; +import org.apache.logging.log4j.Level; import org.jetbrains.annotations.Nullable; import java.util.*; @@ -79,9 +80,7 @@ public class EntryListSearchManager { searchManager.getAsync(list -> { List | CollapsedStack*/ Object> finalList = collapse(copyAndOrder(list)); - if (ConfigObject.getInstance().doDebugSearchTimeRequired()) { - RoughlyEnoughItemsCore.LOGGER.info("Search Used: %s", stopwatch.stop().toString()); - } + InternalLogger.getInstance().log(ConfigObject.getInstance().doDebugSearchTimeRequired() ? Level.INFO : Level.TRACE, "Search Used: %s", stopwatch.stop().toString()); Minecraft.getInstance().executeBlocking(() -> { update.accept(finalList); diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/category/CategoryRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/category/CategoryRegistryImpl.java index ee784a849..5ab3f59a7 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/category/CategoryRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/category/CategoryRegistryImpl.java @@ -25,7 +25,6 @@ package me.shedaniel.rei.impl.client.registry.category; import com.google.common.base.MoreObjects; import dev.architectury.event.EventResult; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.category.ButtonArea; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; @@ -36,10 +35,12 @@ import me.shedaniel.rei.api.client.registry.display.DisplayCategoryView; import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryIngredient; +import me.shedaniel.rei.impl.common.InternalLogger; import org.jetbrains.annotations.ApiStatus; import java.util.*; import java.util.function.Consumer; +import java.util.stream.Collectors; @ApiStatus.Internal public class CategoryRegistryImpl implements CategoryRegistry { @@ -55,6 +56,15 @@ public class CategoryRegistryImpl implements CategoryRegistry { @Override public void startReload() { this.categories.clear(); + this.listeners.clear(); + this.visibilityPredicates.clear(); + } + + @Override + public void endReload() { + InternalLogger.getInstance().debug("Registered %d categories: %s", this.categories.size(), + this.categories.values().stream().map(configuration -> configuration.getCategory().getTitle().getString()) + .collect(Collectors.joining(", "))); } @Override @@ -70,6 +80,8 @@ public class CategoryRegistryImpl implements CategoryRegistry { listener.accept(configuration); } } + + InternalLogger.getInstance().debug("Added category [%s]: %s", category.getCategoryIdentifier(), category.getTitle().getString()); } @Override @@ -106,6 +118,7 @@ public class CategoryRegistryImpl implements CategoryRegistry { public void registerVisibilityPredicate(CategoryVisibilityPredicate predicate) { visibilityPredicates.add(predicate); visibilityPredicates.sort(Comparator.reverseOrder()); + InternalLogger.getInstance().debug("Added category visibility predicate: %s [%.2f priority]", predicate, predicate.getPriority()); } @Override @@ -117,7 +130,7 @@ public class CategoryRegistryImpl implements CategoryRegistry { return result.isEmpty() || result.isTrue(); } } catch (Throwable throwable) { - RoughlyEnoughItemsCore.LOGGER.error("Failed to check if the category is visible!", throwable); + InternalLogger.getInstance().error("Failed to check if the category is visible!", throwable); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java index af84abe0f..bd29f9142 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java @@ -28,7 +28,6 @@ import com.google.common.collect.ForwardingMap; import com.google.common.collect.ForwardingMapEntry; import com.google.common.collect.Iterators; import dev.architectury.event.EventResult; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; @@ -40,6 +39,7 @@ import me.shedaniel.rei.api.client.registry.display.visibility.DisplayVisibility import me.shedaniel.rei.api.common.category.CategoryIdentifier; import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.plugins.PluginManager; +import me.shedaniel.rei.impl.common.InternalLogger; import me.shedaniel.rei.impl.common.registry.RecipeManagerContextImpl; import net.minecraft.world.item.crafting.Recipe; import org.apache.commons.lang3.mutable.MutableInt; @@ -155,7 +155,7 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl 0 && System.currentTimeMillis() - lastAddWarning.getValue() > 5000) { - RoughlyEnoughItemsCore.LOGGER.warn("Detected runtime DisplayRegistry modification, this can be extremely dangerous!"); + InternalLogger.getInstance().warn("Detected runtime DisplayRegistry modification, this can be extremely dangerous!"); } lastAddWarning.setValue(System.currentTimeMillis()); } @@ -179,12 +179,14 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl void registerGlobalDisplayGenerator(DynamicDisplayGenerator generator) { globalDisplayGenerators.add(generator); + InternalLogger.getInstance().debug("Added global display generator: %s", generator); } @Override public void registerDisplayGenerator(CategoryIdentifier categoryId, DynamicDisplayGenerator generator) { displayGenerators.computeIfAbsent(categoryId, location -> new ArrayList<>()) .add(generator); + InternalLogger.getInstance().debug("Added display generator for category [%s]: %s", categoryId, generator); } @Override @@ -201,6 +203,7 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl void registerFiller(Class typeClass, BiPredicate predicate, Function filler) { fillers.add(new DisplayFiller<>((o, s) -> typeClass.isInstance(o) && ((BiPredicate) predicate).test(o, s), (Function) filler)); + InternalLogger.getInstance().debug("Added display filter: %s for %s", filler, typeClass.getName()); } @Override public void registerFiller(Predicate predicate, Function filler) { fillers.add(new DisplayFiller<>((o, s) -> ((Predicate) predicate).test(o), (Function) filler)); + InternalLogger.getInstance().debug("Added display filter: %s", filler); } @Override @@ -263,9 +268,11 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl identifier : displays.keySet()) { if (CategoryRegistry.getInstance().tryGet(identifier).isEmpty()) { - RoughlyEnoughItemsCore.LOGGER.throwException(new IllegalStateException("Displays registered for unknown registry: " + identifier)); + InternalLogger.getInstance().error("Found displays registered for unknown registry", new IllegalStateException(identifier.toString())); } } + + InternalLogger.getInstance().debug("Registered %d displays", displayCount.getValue()); } @Override @@ -307,7 +314,7 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl( + private record DisplayFiller( BiPredicate predicate, Function mappingFunction diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/ExclusionZonesImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/ExclusionZonesImpl.java index 26f7b6773..85b8090f1 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/ExclusionZonesImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/ExclusionZonesImpl.java @@ -27,11 +27,11 @@ import com.google.common.collect.HashMultimap; import com.google.common.collect.Lists; import com.google.common.collect.Multimap; import me.shedaniel.math.Rectangle; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.client.gui.config.DisplayPanelLocation; import me.shedaniel.rei.api.client.registry.screen.ExclusionZones; import me.shedaniel.rei.api.client.registry.screen.ExclusionZonesProvider; import me.shedaniel.rei.api.common.plugins.PluginManager; +import me.shedaniel.rei.impl.common.InternalLogger; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; @@ -142,8 +142,9 @@ public class ExclusionZonesImpl implements ExclusionZones { list.put(screenClass, screen -> ((ExclusionZonesProvider) provider).provide((T) screen)); } + InternalLogger.getInstance().debug("Added exclusion zones provider: %s for %s", provider, screenClass.getName()); if (!PluginManager.areAnyReloading()) { - RoughlyEnoughItemsCore.LOGGER.warn("Detected ExclusionZonesImpl modification at runtime, this may cause issues, a single ExclusionZonesProvider can dynamically provide boundaries instead!", new RuntimeException()); + InternalLogger.getInstance().warn("Detected ExclusionZonesImpl modification at runtime, this may cause issues, a single ExclusionZonesProvider can dynamically provide boundaries instead!", new RuntimeException()); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/ScreenRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/ScreenRegistryImpl.java index ebc42d9f3..9754851cd 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/ScreenRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/screen/ScreenRegistryImpl.java @@ -45,6 +45,7 @@ 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.gui.screen.AbstractDisplayViewingScreen; +import me.shedaniel.rei.impl.common.InternalLogger; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.client.Minecraft; @@ -158,16 +159,14 @@ public class ScreenRegistryImpl implements ScreenRegistry { deciders.sort(Comparator.reverseOrder()); cache.clear(); tmpScreen.remove(); - registerDraggableComponentProvider(DraggableComponentProviderWidget.from(context -> - Widgets.walk(context.getScreen().children(), DraggableComponentProviderWidget.class::isInstance))); - registerDraggableComponentVisitor(DraggableComponentVisitorWidget.from(context -> - Widgets.walk(context.getScreen().children(), DraggableComponentVisitorWidget.class::isInstance))); + InternalLogger.getInstance().debug("Added overlay decider: %s [%.2f priority]", decider, decider.getPriority()); } @Override public void registerFocusedStack(FocusedStackProvider provider) { focusedStackProviders.add(provider); focusedStackProviders.sort(Comparator.reverseOrder()); + InternalLogger.getInstance().debug("Added focused stack provider: %s [%.2f priority]", provider, provider.getPriority()); } @Override @@ -184,12 +183,14 @@ public class ScreenRegistryImpl implements ScreenRegistry { public void registerDraggableComponentProvider(DraggableComponentProvider provider) { draggableProviders.add((DraggableComponentProvider) provider); draggableProviders.sort(Comparator.reverseOrder()); + InternalLogger.getInstance().debug("Added draggable component provider: %s [%.2f priority]", provider, provider.getPriority()); } @Override public void registerDraggableComponentVisitor(DraggableComponentVisitor visitor) { draggableVisitors.add((DraggableComponentVisitor) visitor); draggableVisitors.sort(Comparator.reverseOrder()); + InternalLogger.getInstance().debug("Added draggable component visitor: %s [%.2f priority]", visitor, visitor.getPriority()); } @Override @@ -229,6 +230,7 @@ public class ScreenRegistryImpl implements ScreenRegistry { @Override public void registerClickArea(Class screenClass, ClickArea area) { clickAreas.put(screenClass, area); + InternalLogger.getInstance().debug("Added click area provider for %s: %s", screenClass.getName(), area); } @Override @@ -257,6 +259,11 @@ public class ScreenRegistryImpl implements ScreenRegistry { registerDefault(); } + @Override + public void endReload() { + InternalLogger.getInstance().debug("Registered %d overlay deciders and %d exclusion zones", deciders.size(), exclusionZones.getZonesCount()); + } + private void registerDefault() { registerDecider(this.exclusionZones = new ExclusionZonesImpl()); registerDecider(new DisplayBoundsProvider>() { @@ -316,5 +323,9 @@ public class ScreenRegistryImpl implements ScreenRegistry { return -10.0; } }); + registerDraggableComponentProvider(DraggableComponentProviderWidget.from(context -> + Widgets.walk(context.getScreen().children(), DraggableComponentProviderWidget.class::isInstance))); + registerDraggableComponentVisitor(DraggableComponentVisitorWidget.from(context -> + Widgets.walk(context.getScreen().children(), DraggableComponentVisitorWidget.class::isInstance))); } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/SearchProviderImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/SearchProviderImpl.java index ab59401db..c56d30b26 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/SearchProviderImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/SearchProviderImpl.java @@ -33,6 +33,7 @@ import me.shedaniel.rei.impl.client.search.argument.Argument; import me.shedaniel.rei.impl.client.search.argument.CompoundArgument; import me.shedaniel.rei.impl.client.search.argument.type.ArgumentType; import me.shedaniel.rei.impl.client.util.CrashReportUtils; +import me.shedaniel.rei.impl.common.InternalLogger; import net.minecraft.CrashReport; import net.minecraft.CrashReportCategory; @@ -68,6 +69,7 @@ public class SearchProviderImpl implements SearchProvider { .map(Argument::getArgument) .distinct() .collect(Collectors.toList())); + InternalLogger.getInstance().debug("Created search filter with %s using %s", filter, inputMethod.getName().getString()); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/method/InputMethodRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/method/InputMethodRegistryImpl.java index fc6b955fb..8cac7824a 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/search/method/InputMethodRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/search/method/InputMethodRegistryImpl.java @@ -39,6 +39,7 @@ import java.util.Map; import java.util.Objects; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; +import java.util.stream.Collectors; public class InputMethodRegistryImpl implements InputMethodRegistry { private final Map> inputMethods = Maps.newHashMap(); @@ -46,6 +47,7 @@ public class InputMethodRegistryImpl implements InputMethodRegistry { @Override public void add(ResourceLocation id, InputMethod inputMethod) { this.inputMethods.put(id, inputMethod); + InternalLogger.getInstance().debug("Added input method [%s]: %s", id, inputMethod.getName().getString()); } @Override @@ -95,6 +97,9 @@ public class InputMethodRegistryImpl implements InputMethodRegistry { } }).join(); service.shutdown(); + + InternalLogger.getInstance().debug("Registered %d input methods: ", inputMethods.size(), + inputMethods.values().stream().map(inputMethod -> inputMethod.getName().getString()).collect(Collectors.joining(", "))); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/transfer/TransferHandlerRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/transfer/TransferHandlerRegistryImpl.java index 43b20634b..93cffb1fe 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/transfer/TransferHandlerRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/transfer/TransferHandlerRegistryImpl.java @@ -29,6 +29,7 @@ import me.shedaniel.rei.api.client.registry.transfer.TransferHandler; import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRegistry; import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.impl.ClientInternals; +import me.shedaniel.rei.impl.common.InternalLogger; import net.minecraft.world.inventory.tooltip.TooltipComponent; import org.jetbrains.annotations.ApiStatus; @@ -52,10 +53,16 @@ public class TransferHandlerRegistryImpl implements TransferHandlerRegistry { handlers.clear(); } + @Override + public void endReload() { + InternalLogger.getInstance().debug("Registered %d transfer handlers", handlers.size()); + } + @Override public void register(TransferHandler handler) { handlers.add(handler); handlers.sort(Comparator.reverseOrder()); + InternalLogger.getInstance().debug("Added transfer handler: %s [%.2f priority]", handler, handler.getPriority()); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java index 39b45c0f1..1c579e2e5 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/view/ViewsImpl.java @@ -30,7 +30,6 @@ import com.google.common.collect.Sets; import it.unimi.dsi.fastutil.longs.Long2LongMap; import it.unimi.dsi.fastutil.longs.Long2LongMaps; import it.unimi.dsi.fastutil.longs.Long2LongOpenHashMap; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.registry.category.CategoryRegistry; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; @@ -57,6 +56,7 @@ import me.shedaniel.rei.api.common.util.EntryStacks; import me.shedaniel.rei.impl.client.gui.craftable.CraftableFilter; import me.shedaniel.rei.impl.client.gui.widget.AutoCraftingEvaluator; import me.shedaniel.rei.impl.client.util.CrashReportUtils; +import me.shedaniel.rei.impl.common.InternalLogger; import me.shedaniel.rei.impl.display.DisplaySpec; import net.minecraft.CrashReport; import net.minecraft.ReportedException; @@ -95,7 +95,7 @@ public class ViewsImpl implements Views { private static Map, List> _buildMapFor(ViewSearchBuilder builder) { if (PluginManager.areAnyReloading()) { - RoughlyEnoughItemsCore.LOGGER.info("Cancelled Views buildMap since plugins have not finished reloading."); + InternalLogger.getInstance().info("Cancelled Views buildMap since plugins have not finished reloading."); return Maps.newLinkedHashMap(); } @@ -283,9 +283,9 @@ public class ViewsImpl implements Views { String message = String.format("Built Recipe View in %s for %d categories, %d recipes for, %d usages for and %d live recipe generators.", stopwatch.stop(), categories.size(), recipesForStacks.size(), usagesForStacks.size(), generatorsCount); if (ConfigObject.getInstance().doDebugSearchTimeRequired()) { - RoughlyEnoughItemsCore.LOGGER.info(message); + InternalLogger.getInstance().info(message); } else { - RoughlyEnoughItemsCore.LOGGER.trace(message); + InternalLogger.getInstance().trace(message); } return resultSpeced; } @@ -374,7 +374,7 @@ public class ViewsImpl implements Views { } catch (Throwable throwable) { CrashReport report = CrashReportUtils.essential(throwable, "Error while generating recipes for an entry stack"); CrashReportUtils.renderer(report, entry); - RoughlyEnoughItemsCore.LOGGER.throwException(new ReportedException(report)); + InternalLogger.getInstance().throwException(new ReportedException(report)); return Optional.empty(); } } @@ -386,7 +386,7 @@ public class ViewsImpl implements Views { } catch (Throwable throwable) { CrashReport report = CrashReportUtils.essential(throwable, "Error while generating usages for an entry stack"); CrashReportUtils.renderer(report, entry); - RoughlyEnoughItemsCore.LOGGER.throwException(new ReportedException(report)); + InternalLogger.getInstance().throwException(new ReportedException(report)); return Optional.empty(); } } @@ -397,7 +397,7 @@ public class ViewsImpl implements Views { return generator.generate(builder); } catch (Throwable throwable) { CrashReport report = CrashReportUtils.essential(throwable, "Error while generating recipes for a search"); - RoughlyEnoughItemsCore.LOGGER.throwException(new ReportedException(report)); + InternalLogger.getInstance().throwException(new ReportedException(report)); return Optional.empty(); } } @@ -493,7 +493,7 @@ public class ViewsImpl implements Views { display.getOutputEntries().stream().flatMap(Collection::stream).collect(Collectors.toCollection(() -> craftables)); } } catch (Throwable t) { - RoughlyEnoughItemsCore.LOGGER.warn("Error while checking if display is craftable", t); + InternalLogger.getInstance().warn("Error while checking if display is craftable", t); } } } 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 eeea8ab25..293f3bc3e 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 @@ -39,6 +39,7 @@ import me.shedaniel.rei.api.common.entry.type.VanillaEntryTypes; 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.common.InternalLogger; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; import net.minecraft.core.NonNullList; @@ -98,6 +99,7 @@ public class EntryRegistryImpl implements EntryRegistry { registryList = new NormalEntryRegistryList(registryList.stream().filter(((Predicate>) EntryStack::isEmpty).negate())); refilter(); REIRuntime.getInstance().getOverlay().ifPresent(ScreenOverlay::queueReloadOverlay); + InternalLogger.getInstance().debug("Reloaded entry registry with %d entries and %d filtered entries", size(), getPreFilteredList().size()); } @Override diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/PreFilteredEntryList.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/PreFilteredEntryList.java index 3b0a73f3a..ece25fb3d 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/PreFilteredEntryList.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/PreFilteredEntryList.java @@ -26,7 +26,6 @@ package me.shedaniel.rei.impl.common.entry.type; import com.google.common.base.Stopwatch; import com.google.common.collect.Lists; import it.unimi.dsi.fastutil.longs.LongList; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.client.REIRuntime; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.config.entry.EntryStackProvider; @@ -39,6 +38,7 @@ import me.shedaniel.rei.impl.client.entry.filtering.FilteringCacheImpl; import me.shedaniel.rei.impl.client.entry.filtering.FilteringContextImpl; import me.shedaniel.rei.impl.client.entry.filtering.FilteringContextType; import me.shedaniel.rei.impl.client.entry.filtering.FilteringRule; +import me.shedaniel.rei.impl.common.InternalLogger; import me.shedaniel.rei.impl.common.util.HashedEntryStackWrapper; import org.apache.commons.lang3.mutable.MutableLong; import org.jetbrains.annotations.Nullable; @@ -142,7 +142,7 @@ public class PreFilteredEntryList implements EntryRegistryListener { FilteringRule rule = rules.get(i); cache.setCache(rule, rule.prepareCache(true)); context.handleResult(rule.processFilteredStacks(context, cache, true)); - RoughlyEnoughItemsCore.LOGGER.debug("Refiltered rule [%s] in %s.", FilteringRule.REGISTRY.inverse().get(rule).toString(), innerStopwatch.stop().toString()); + InternalLogger.getInstance().debug("Refiltered rule [%s] in %s.", FilteringRule.REGISTRY.inverse().get(rule).toString(), innerStopwatch.stop().toString()); } Set hiddenStacks = context.stacks.get(FilteringContextType.HIDDEN); @@ -156,13 +156,13 @@ public class PreFilteredEntryList implements EntryRegistryListener { .collect(Collectors.toCollection(Lists::newCopyOnWriteArrayList)); } - RoughlyEnoughItemsCore.LOGGER.debug("Refiltered %d entries with %d rules in %s.", stacks.size() - preFilteredList.size(), rules.size(), stopwatch.stop().toString()); + InternalLogger.getInstance().debug("Refiltered %d entries with %d rules in %s.", stacks.size() - preFilteredList.size(), rules.size(), stopwatch.stop().toString()); } public Collection> refilterNew(boolean warn, Collection> entries) { if (lastRefilterWarning != null && warn) { if (lastRefilterWarning.getValue() > 0 && System.currentTimeMillis() - lastRefilterWarning.getValue() > 5000) { - RoughlyEnoughItemsCore.LOGGER.warn("Detected runtime EntryRegistry modification, this can be extremely dangerous, or be extremely inefficient!"); + InternalLogger.getInstance().warn("Detected runtime EntryRegistry modification, this can be extremely dangerous, or be extremely inefficient!"); } lastRefilterWarning.setValue(System.currentTimeMillis()); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/collapsed/CollapsibleEntryRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/collapsed/CollapsibleEntryRegistryImpl.java index cf937adfc..69b86f397 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/collapsed/CollapsibleEntryRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/entry/type/collapsed/CollapsibleEntryRegistryImpl.java @@ -29,6 +29,7 @@ import me.shedaniel.rei.api.client.plugins.REIClientPlugin; import me.shedaniel.rei.api.client.registry.entry.CollapsibleEntryRegistry; import me.shedaniel.rei.api.common.entry.EntryStack; import me.shedaniel.rei.api.common.util.EntryStacks; +import me.shedaniel.rei.impl.common.InternalLogger; import net.minecraft.network.chat.Component; import net.minecraft.resources.ResourceLocation; @@ -36,6 +37,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; import java.util.function.Predicate; +import java.util.stream.Collectors; public class CollapsibleEntryRegistryImpl implements CollapsibleEntryRegistry { private final List entries = new ArrayList<>(); @@ -44,12 +46,14 @@ public class CollapsibleEntryRegistryImpl implements CollapsibleEntryRegistry { public void group(ResourceLocation id, Component name, List> stacks) { Objects.requireNonNull(stacks, "stacks"); this.entries.add(new Entry(id.getNamespace(), name, new ListMatcher(stacks))); + InternalLogger.getInstance().debug("Added collapsible entry group [%s] %s with %d entries", id, name.getString(), stacks.size()); } @Override public void group(ResourceLocation id, Component name, Predicate> predicate) { Objects.requireNonNull(predicate, "predicate"); this.entries.add(new Entry(id.getNamespace(), name, (stack, hashExact) -> ((Predicate>) predicate).test(stack))); + InternalLogger.getInstance().debug("Added collapsible entry group [%s] %s with dynamic predicate", id, name.getString()); } @Override @@ -57,6 +61,12 @@ public class CollapsibleEntryRegistryImpl implements CollapsibleEntryRegistry { this.entries.clear(); } + @Override + public void endReload() { + InternalLogger.getInstance().debug("Registered %d collapsible entry groups: ", entries.size(), + entries.stream().map(entry -> entry.getName().getString()).collect(Collectors.joining(", "))); + } + @Override public void acceptPlugin(REIClientPlugin plugin) { plugin.registerCollapsibleEntries(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 8dbeab494..1264b9abf 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 @@ -39,6 +39,7 @@ 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 me.shedaniel.rei.impl.common.InternalLogger; import me.shedaniel.rei.impl.common.logging.performance.PerformanceLogger; import net.minecraft.client.Minecraft; import net.minecraft.server.MinecraftServer; @@ -49,9 +50,7 @@ import org.jetbrains.annotations.Nullable; import java.io.Closeable; import java.util.*; import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; -import java.util.function.LongConsumer; import java.util.function.UnaryOperator; @ApiStatus.Internal @@ -64,16 +63,14 @@ public class PluginManagerImpl

> implements PluginManager< private ReloadStage reloading = null; private List observedStages = new ArrayList<>(); private final List> plugins = new ArrayList<>(); - private final LongConsumer reloadDoneListener; private final Stopwatch reloadStopwatch = Stopwatch.createUnstarted(); private boolean forcedMainThread; private final Stopwatch forceMainThreadStopwatch = Stopwatch.createUnstarted(); @SafeVarargs - public PluginManagerImpl(Class

pluginClass, UnaryOperator> view, LongConsumer reloadDoneListener, Reloadable... reloadables) { + public PluginManagerImpl(Class

pluginClass, UnaryOperator> view, Reloadable... reloadables) { this.pluginClass = pluginClass; this.view = view; - this.reloadDoneListener = reloadDoneListener; for (Reloadable reloadable : reloadables) { registerReloadable(reloadable); } @@ -116,7 +113,7 @@ public class PluginManagerImpl

> implements PluginManager< @Override public void registerPlugin(REIPluginProvider plugin) { plugins.add((REIPluginProvider

) plugin); - RoughlyEnoughItemsCore.LOGGER.info("Registered plugin provider %s for %s", plugin.getPluginProviderName(), name(pluginClass)); + InternalLogger.getInstance().info("Registered plugin provider %s for %s", plugin.getPluginProviderName(), name(pluginClass)); } @Override @@ -161,7 +158,7 @@ public class PluginManagerImpl

> implements PluginManager< this.stage = stage; this.sectionData = new MutablePair<>(Stopwatch.createUnstarted(), ""); sectionData.setRight(section); - RoughlyEnoughItemsCore.LOGGER.debug("[" + stage + "] Reloading Section: \"%s\"", section); + InternalLogger.getInstance().trace("[" + stage + "] Reloading Section: \"%s\"", section); sectionData.getLeft().reset().start(); } @@ -169,7 +166,7 @@ public class PluginManagerImpl

> implements PluginManager< public void close() { sectionData.getLeft().stop(); String section = sectionData.getRight(); - RoughlyEnoughItemsCore.LOGGER.debug("[" + stage + "] Reloading Section: \"%s\" done in %s", section, sectionData.getLeft().toString()); + InternalLogger.getInstance().trace("[" + stage + "] Reloading Section: \"%s\" done in %s", section, sectionData.getLeft().toString()); sectionData.getLeft().reset(); } } @@ -193,7 +190,7 @@ public class PluginManagerImpl

> implements PluginManager< try { forcedMainThread = true; forceMainThreadStopwatch.start(); - RoughlyEnoughItemsCore.LOGGER.warn("Forcing plugin " + wrapper.getPluginProviderName() + " to run on the main thread for " + sectionName + "! This is extremely dangerous, and have large performance implications."); + InternalLogger.getInstance().warn("Forcing plugin " + wrapper.getPluginProviderName() + " to run on the main thread for " + sectionName + "! This is extremely dangerous, and have large performance implications."); if (Platform.getEnvironment() == Env.CLIENT) { EnvExecutor.runInEnv(Env.CLIENT, () -> () -> queueExecutionClient(runnable)); } else { @@ -205,7 +202,7 @@ public class PluginManagerImpl

> implements PluginManager< } }); } catch (Throwable throwable) { - RoughlyEnoughItemsCore.LOGGER.error(wrapper.getPluginProviderName() + " plugin failed to " + sectionName + "!", throwable); + InternalLogger.getInstance().error(wrapper.getPluginProviderName() + " plugin failed to " + sectionName + "!", throwable); } } } @@ -265,9 +262,9 @@ public class PluginManagerImpl

> implements PluginManager< new RuntimeException("Failed to run post registration").printStackTrace(); } this.reloadStopwatch.stop(); - reloadDoneListener.accept(this.reloadStopwatch.elapsed(TimeUnit.MILLISECONDS)); + InternalLogger.getInstance().info("Reloaded Plugin Manager [%s] with %d plugins in %s.", pluginClass.getSimpleName(), plugins.size(), reloadStopwatch); if (forcedMainThread) { - RoughlyEnoughItemsCore.LOGGER.warn("Forcing plugins to run on main thread took " + forceMainThreadStopwatch); + InternalLogger.getInstance().warn("Forcing plugins to run on main thread took " + forceMainThreadStopwatch); } } @@ -300,7 +297,7 @@ public class PluginManagerImpl

> implements PluginManager< // Sort Plugins List> plugins = new ArrayList<>(getPluginWrapped().toList()); plugins.sort(Comparator.comparingDouble(PluginWrapper

::getPriority).reversed()); - RoughlyEnoughItemsCore.LOGGER.info("Reloading Plugin Manager [%s] stage [%s], registered %d plugins: %s", name(pluginClass), stage.toString(), plugins.size(), CollectionUtils.mapAndJoinToString(plugins, PluginWrapper::getPluginProviderName, ", ")); + 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 diff --git a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/FilteredStacksVisibilityHandler.java b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/FilteredStacksVisibilityHandler.java index 13379c29a..3bdca8c15 100644 --- a/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/FilteredStacksVisibilityHandler.java +++ b/runtime/src/main/java/me/shedaniel/rei/plugin/client/runtime/FilteredStacksVisibilityHandler.java @@ -28,7 +28,6 @@ import dev.architectury.event.EventResult; import it.unimi.dsi.fastutil.objects.Reference2BooleanMap; import it.unimi.dsi.fastutil.objects.Reference2BooleanMaps; import it.unimi.dsi.fastutil.objects.Reference2BooleanOpenHashMap; -import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.client.config.ConfigObject; import me.shedaniel.rei.api.client.registry.display.DisplayCategory; import me.shedaniel.rei.api.client.registry.display.DisplayRegistry; @@ -37,6 +36,7 @@ import me.shedaniel.rei.api.common.display.Display; import me.shedaniel.rei.api.common.entry.EntryIngredient; import me.shedaniel.rei.impl.client.config.ConfigObjectImpl; import me.shedaniel.rei.impl.client.entry.filtering.*; +import me.shedaniel.rei.impl.common.InternalLogger; import java.util.List; import java.util.function.Predicate; @@ -87,7 +87,7 @@ public class FilteredStacksVisibilityHandler implements DisplayVisibilityPredica }).forEach(map -> { visible.putAll(map); }); - RoughlyEnoughItemsCore.LOGGER.debug("Computed existing filtered displays with %d rules in %s", filteringRules.size(), stopwatch.stop()); + InternalLogger.getInstance().debug("Computed existing filtered displays with %d rules in %s", filteringRules.size(), stopwatch.stop()); } private boolean checkHiddenStacks(Display display) { diff --git a/runtime/src/main/resources/assets/roughlyenoughitems/lang/vi_vn.json b/runtime/src/main/resources/assets/roughlyenoughitems/lang/vi_vn.json new file mode 100644 index 000000000..1768023d3 --- /dev/null +++ b/runtime/src/main/resources/assets/roughlyenoughitems/lang/vi_vn.json @@ -0,0 +1,146 @@ +{ + "text.rei.cheating": "Gian lận", + "text.rei.cheating_disabled": "§7Gian lận bị vô hiệu hóa", + "text.rei.cheating_enabled": "§cGian lận được kích hoạt", + "text.rei.cheating_limited_enabled": "\n§bĐã bật gian lận (Sử dụng lệnh)", + "text.rei.cheating_enabled_no_perms": "§7Gian lận §cĐược Kích Hoạt §7(Không được phép)", + "text.rei.cheating_limited_creative_enabled": "§aĐã bật gian lận (Sử dụng chế độ sáng tạo)", + "text.rei.no_permission_cheat": "Yêu cầu quyền điều hành để cheat vật phẩm", + "text.rei.search.field.suggestion": "Tìm kiếm...", + "text.rei.feedback": "Bạn có bất kỳ phản hồi nào muốn cung cấp cho nhà phát triển REI? %s để gửi phản hồi của bạn!", + "text.rei.feedback.link": "Nhấp vào đây để truy cập Google Form", + "text.rei.support.me": "Hỗ trợ tôi để tiếp tục phát triển REI tốt hơn!", + "text.rei.support.me.desc": "Với tư cách là người ủng hộ REI trên patreon, bạn có thể sử dụng phiên bản REI mới nhất cho Minecraft snapshots.\nNgoài ra, bạn cũng có thể hỗ trợ tôi về mặt tài chính thông qua việc thuê máy chủ BisectHosting.\n\n%s\n%s", + "text.rei.support.me.patreon": "Ủng hộ trên Patreon", + "text.rei.support.me.bisect": "Sử dụng mã SHEDANIEL trên BisectHosting", + "text.rei.not.fully.initialized": "REI chưa được khởi tạo hoàn toàn!", + "text.rei.not.fully.initialized.tooltip": "Các giai đoạn bị thiếu:%s\nNếu điều này không biến mất,\nhãy thử tìm hỗ trợ với các bản ghi!", + "text.rei.inventory.highlighting.enabled": "Bật đánh dấu túi đồ", + "text.rei.inventory.highlighting.enabled.tooltip": "Điều này sẽ làm cho các vị trí không khớp\nvới bộ lọc tìm kiếm sẽ trở thành màu xám.\nNhấp đúp vào thanh tìm kiếm để chuyển đổi chế độ này.\n", + "text.rei.caching.search": "REI đang lưu kết quả tìm kiếm vào bộ nhớ đệm...", + "text.rei.caching.search.step": "Bước %d/%d (%s%%):", + "text.rei.config.menu.dark_theme": "Chế độ tối", + "text.rei.config.menu.craftable_filter": "Bộ lọc có thể chế tạo", + "text.rei.config.menu.display": "Cài đặt hiển thị...", + "text.rei.config.menu.display.remove_recipe_book": "Xóa sách công thức", + "text.rei.config.menu.display.left_side_mob_effects": "Hiệu ứng Mob nằm bên trái", + "text.rei.config.menu.display.left_side_panel": "Bảng điều khiển nằm bên trái", + "text.rei.config.menu.display.side_search_field": "Trường tìm kiếm nằm bên cạnh", + "text.rei.config.menu.display.syntax_highlighting": "Đánh dấu cú pháp", + "text.rei.config.menu.config": "Các tuỳ chọn khác...", + "category.rei.crafting": "Chế tạo", + "category.rei.smelting": "Nung chảy", + "category.rei.smelting.fuel": "Nhiên liệu", + "category.rei.fuel": "Nhiên liệu", + "category.rei.fuel.time": "Thời gian nung: %d ticks", + "category.rei.fuel.time.items": "Thời gian nung: %s vật phẩm", + "category.rei.fuel.time_short": "%d ticks", + "category.rei.fuel.time_short.items": "%s vật phẩm", + "category.rei.cooking.xp": "%f Kinh Nghiệm", + "category.rei.cooking.time&xp": "%s Kinh nghiệm trong %s giây", + "category.rei.smoking": "Hun khói", + "category.rei.blasting": "Luyện kim", + "category.rei.campfire": "Lửa trại", + "category.rei.campfire.time": "%s giây", +