1
mirror of https://github.com/StarWishsama/Slimefun4.git synced 2024-09-19 19:25:48 +00:00

Merge pull request #3448 from StarWishsama/chore/guide-search-improve

Improve guide search result
This commit is contained in:
TheBusyBiscuit 2022-03-09 15:55:18 +01:00 committed by GitHub
commit e9ab775630
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 4 deletions

View File

@ -103,7 +103,8 @@ public final class SlimefunRegistry {
guideKey = new NamespacedKey(plugin, "slimefun_guide_mode");
boolean showVanillaRecipes = cfg.getBoolean("guide.show-vanilla-recipes");
guides.put(SlimefunGuideMode.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes));
boolean showHiddenItemGroupsInSearch = cfg.getBoolean("guide.show-hidden-item-groups-in-search");
guides.put(SlimefunGuideMode.SURVIVAL_MODE, new SurvivalSlimefunGuide(showVanillaRecipes, showHiddenItemGroupsInSearch));
guides.put(SlimefunGuideMode.CHEAT_MODE, new CheatSheetSlimefunGuide());
researchRanks.addAll(cfg.getStringList("research-ranks"));

View File

@ -34,7 +34,7 @@ public class CheatSheetSlimefunGuide extends SurvivalSlimefunGuide {
private final ItemStack item;
public CheatSheetSlimefunGuide() {
super(false);
super(false, true);
item = new SlimefunGuideItem(this, "&cSlimefun Guide &4(Cheat Sheet)");
}

View File

@ -72,9 +72,11 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
private final int[] recipeSlots = { 3, 4, 5, 12, 13, 14, 21, 22, 23 };
private final ItemStack item;
private final boolean showVanillaRecipes;
private final boolean showHiddenItemGroupsInSearch;
public SurvivalSlimefunGuide(boolean showVanillaRecipes) {
public SurvivalSlimefunGuide(boolean showVanillaRecipes, boolean showHiddenItemGroupsInSearch) {
this.showVanillaRecipes = showVanillaRecipes;
this.showHiddenItemGroupsInSearch = showHiddenItemGroupsInSearch;
item = new SlimefunGuideItem(this, "&aSlimefun Guide &7(Chest GUI)");
}
@ -358,7 +360,9 @@ public class SurvivalSlimefunGuide implements SlimefunGuideImplementation {
break;
}
if (!slimefunItem.isHidden() && isSearchFilterApplicable(slimefunItem, searchTerm)) {
boolean isItemGroupHidden = showHiddenItemGroupsInSearch || !slimefunItem.getItemGroup().isHidden(p);
if (!slimefunItem.isHidden() && isItemGroupHidden && isSearchFilterApplicable(slimefunItem, searchTerm)) {
ItemStack itemstack = new CustomItemStack(slimefunItem.getItem(), meta -> {
ItemGroup itemGroup = slimefunItem.getItemGroup();
meta.setLore(Arrays.asList("", ChatColor.DARK_GRAY + "\u21E8 " + ChatColor.WHITE + itemGroup.getDisplayName(p)));

View File

@ -23,6 +23,7 @@ options:
guide:
show-vanilla-recipes: true
receive-on-first-join: true
show-hidden-item-groups-in-search: false
researches:
free-in-creative-mode: true