Prechádzať zdrojové kódy

Remove Perfer Visible Recipes

Unknown 6 rokov pred
rodič
commit
d6ac1ad9c2

+ 1 - 1
src/main/java/me/shedaniel/rei/api/DisplayVisibility.java

@@ -7,7 +7,7 @@ package me.shedaniel.rei.api;
 
 public enum DisplayVisibility {
     ALWAYS_VISIBLE,
-    CONFIG_OPTIONAL,
+    @Deprecated CONFIG_OPTIONAL,
     NEVER_VISIBLE,
     PASS
 }

+ 0 - 1
src/main/java/me/shedaniel/rei/api/DisplayVisibilityHandler.java

@@ -20,7 +20,6 @@ public interface DisplayVisibilityHandler {
      * Handles the visibility of the display.
      * {@link DisplayVisibility#PASS} to pass the handling to another handler
      * {@link DisplayVisibility#ALWAYS_VISIBLE} to always display it
-     * {@link DisplayVisibility#CONFIG_OPTIONAL} to allow user to configure the visibility
      * {@link DisplayVisibility#NEVER_VISIBLE} to never display it
      *
      * @param category the category of the display

+ 10 - 0
src/main/java/me/shedaniel/rei/api/RecipeHelper.java

@@ -162,9 +162,19 @@ public interface RecipeHelper {
      * @param display       the display to be checked
      * @param respectConfig whether it should respect the user's config
      * @return whether the display should be visible
+     * @deprecated {@link RecipeHelper#isDisplayVisible(RecipeDisplay)} )}
      */
+    @Deprecated
     boolean isDisplayVisible(RecipeDisplay display, boolean respectConfig);
     
+    /**
+     * Checks if the display is visible by asking recipe visibility handlers
+     *
+     * @param display the display to be checked
+     * @return whether the display should be visible
+     */
+    boolean isDisplayVisible(RecipeDisplay display);
+    
     /**
      * Gets the cached category setting by the category identifier
      *

+ 0 - 2
src/main/java/me/shedaniel/rei/client/ConfigObject.java

@@ -42,8 +42,6 @@ public class ConfigObject {
     
     @Comment("Disable Recipe Book") public boolean disableRecipeBook = false;
     
-    public boolean preferVisibleRecipes = false;
-    
     @Comment("Force enable 2019 REI April Fools' joke") public boolean aprilFoolsFish2019 = false;
     
     public ItemCheatingMode itemCheatingMode = ItemCheatingMode.REI_LIKE;

+ 12 - 8
src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java

@@ -106,7 +106,7 @@ public class RecipeHelperImpl implements RecipeHelper {
         Map<RecipeCategory, List<RecipeDisplay>> recipeCategoryListMap = Maps.newLinkedHashMap();
         categories.forEach(category -> {
             if (categoriesMap.containsKey(category.getIdentifier()) && !categoriesMap.get(category.getIdentifier()).isEmpty())
-                recipeCategoryListMap.put(category, categoriesMap.get(category.getIdentifier()).stream().filter(display -> isDisplayVisible(display, true)).collect(Collectors.toList()));
+                recipeCategoryListMap.put(category, categoriesMap.get(category.getIdentifier()).stream().filter(display -> isDisplayVisible(display)).collect(Collectors.toList()));
         });
         for(RecipeCategory category : Lists.newArrayList(recipeCategoryListMap.keySet()))
             if (recipeCategoryListMap.get(category).isEmpty())
@@ -149,7 +149,7 @@ public class RecipeHelperImpl implements RecipeHelper {
         Map<RecipeCategory, List<RecipeDisplay>> recipeCategoryListMap = Maps.newLinkedHashMap();
         categories.forEach(category -> {
             if (categoriesMap.containsKey(category.getIdentifier()) && !categoriesMap.get(category.getIdentifier()).isEmpty())
-                recipeCategoryListMap.put(category, categoriesMap.get(category.getIdentifier()).stream().filter(display -> isDisplayVisible(display, true)).collect(Collectors.toList()));
+                recipeCategoryListMap.put(category, categoriesMap.get(category.getIdentifier()).stream().filter(display -> isDisplayVisible(display)).collect(Collectors.toList()));
         });
         for(RecipeCategory category : Lists.newArrayList(recipeCategoryListMap.keySet()))
             if (recipeCategoryListMap.get(category).isEmpty())
@@ -265,7 +265,7 @@ public class RecipeHelperImpl implements RecipeHelper {
         Map<RecipeCategory, List<RecipeDisplay>> map = Maps.newLinkedHashMap();
         categories.forEach(recipeCategory -> {
             if (recipeCategoryListMap.containsKey(recipeCategory.getIdentifier())) {
-                List<RecipeDisplay> list = recipeCategoryListMap.get(recipeCategory.getIdentifier()).stream().filter(display -> isDisplayVisible(display, true)).collect(Collectors.toList());
+                List<RecipeDisplay> list = recipeCategoryListMap.get(recipeCategory.getIdentifier()).stream().filter(display -> isDisplayVisible(display)).collect(Collectors.toList());
                 if (!list.isEmpty())
                     map.put(recipeCategory, list);
             }
@@ -288,17 +288,21 @@ public class RecipeHelperImpl implements RecipeHelper {
         return Collections.unmodifiableList(displayVisibilityHandlers);
     }
     
+    @SuppressWarnings("deprecation")
     @Override
     public boolean isDisplayVisible(RecipeDisplay display, boolean respectConfig) {
+        return isDisplayVisible(display);
+    }
+    
+    @SuppressWarnings("deprecation")
+    @Override
+    public boolean isDisplayVisible(RecipeDisplay display) {
         RecipeCategory category = getCategory(display.getRecipeCategory());
         List<DisplayVisibilityHandler> list = getDisplayVisibilityHandlers().stream().sorted(VISIBILITY_HANDLER_COMPARATOR).collect(Collectors.toList());
         for(DisplayVisibilityHandler displayVisibilityHandler : list) {
             DisplayVisibility visibility = displayVisibilityHandler.handleDisplay(category, display);
-            if (visibility != DisplayVisibility.PASS) {
-                if (visibility == DisplayVisibility.CONFIG_OPTIONAL)
-                    return RoughlyEnoughItemsCore.getConfigManager().getConfig().preferVisibleRecipes || !respectConfig;
-                return visibility == DisplayVisibility.ALWAYS_VISIBLE;
-            }
+            if (visibility != DisplayVisibility.PASS)
+                return visibility == DisplayVisibility.ALWAYS_VISIBLE || visibility == DisplayVisibility.CONFIG_OPTIONAL;
         }
         return true;
     }

+ 0 - 1
src/main/java/me/shedaniel/rei/utils/ClothScreenRegistry.java

@@ -66,7 +66,6 @@ public class ClothScreenRegistry {
         });
         appearance.addOption(new IntegerSliderEntry("text.rei.config.max_recipes_per_page", 2, 99, RoughlyEnoughItemsCore.getConfigManager().getConfig().maxRecipePerPage, RESET, () -> 3, i -> RoughlyEnoughItemsCore.getConfigManager().getConfig().maxRecipePerPage = i, () -> getConfigTooltip("max_recipes_per_page")));
         appearance.addOption(new BooleanListEntry("text.rei.config.light_gray_recipe_border", RoughlyEnoughItemsCore.getConfigManager().getConfig().lightGrayRecipeBorder, RESET, () -> false, bool -> RoughlyEnoughItemsCore.getConfigManager().getConfig().lightGrayRecipeBorder = bool, () -> getConfigTooltip("light_gray_recipe_border")));
-        appearance.addOption(new BooleanListEntry("text.rei.config.prefer_visible_recipes", RoughlyEnoughItemsCore.getConfigManager().getConfig().preferVisibleRecipes, RESET, () -> false, bool -> RoughlyEnoughItemsCore.getConfigManager().getConfig().preferVisibleRecipes = bool, () -> getConfigTooltip("prefer_visible_recipes")));
         ConfigScreenBuilder.CategoryBuilder action = builder.addCategory("text.rei.config.action");
         action.addOption(new EnumListEntry<>("text.rei.config.item_cheating_mode", ItemCheatingMode.class, RoughlyEnoughItemsCore.getConfigManager().getConfig().itemCheatingMode, RESET, () -> ItemCheatingMode.REI_LIKE, i -> RoughlyEnoughItemsCore.getConfigManager().getConfig().itemCheatingMode = i, e -> {
             return I18n.translate("text.rei.config.item_cheating_mode." + e.name().toLowerCase());