diff options
| author | Conutik <60240193+Conutik@users.noreply.github.com> | 2024-08-04 17:11:44 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-08-04 16:11:44 +0200 |
| commit | 17bce62559a449f770602512603a3af88b663b18 (patch) | |
| tree | 0dcd39bba5915aae8f1e0b960f43dab56a08d8e2 /src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java | |
| parent | 30fea5f435098d2089444952d8bc02db5dcf41e7 (diff) | |
| download | notenoughupdates-17bce62559a449f770602512603a3af88b663b18.tar.gz notenoughupdates-17bce62559a449f770602512603a3af88b663b18.tar.bz2 notenoughupdates-17bce62559a449f770602512603a3af88b663b18.zip | |
Add Recipe Search Overlay (#1045)
Co-authored-by: nopo <nopotheemail@gmail.com>
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java')
| -rw-r--r-- | src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java index 43035ca8..f9e55203 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NEUManager.java @@ -408,6 +408,11 @@ public class NEUManager { return getRecipesFor(internalname).stream().filter(NeuRecipe::isAvailable).collect(Collectors.toList()); } + public HashMap<String, Set<NeuRecipe>> getAllRecipes() { + return recipesMap; + + } + public Set<NeuRecipe> getUsagesFor(String internalName) { return usagesMap.getOrDefault(internalName, Collections.emptySet()); } @@ -421,12 +426,11 @@ public class NEUManager { String match; DebugMatch(int index, String match) { - this.index = index; - this.match = match; + this.index = index; + this.match = match; } } - private String searchDebug(String[] searchArray, ArrayList<DebugMatch> debugMatches) { //splitToSearch, debugMatches and query final String ANSI_RED = "\u001B[31m"; @@ -502,10 +506,10 @@ public class NEUManager { for (int k = 0; k < splitToSearch.length; k++) { if (queryIndex - 1 != -1 && (queryArray.length - queryIndex) > (splitToSearch.length - k)) continue; if (splitToSearch[k].startsWith(currentSearch)) { - if (((lastStringMatch != -1 ? lastStringMatch : k-1) == k-1)) { + if (((lastStringMatch != -1 ? lastStringMatch : k - 1) == k - 1)) { debugMatches.add(new DebugMatch(k, currentSearch)); lastStringMatch = k; - if (queryIndex+1 != queryArray.length) { + if (queryIndex + 1 != queryArray.length) { queryIndex++; currentSearch = queryArray[queryIndex]; } else { @@ -521,11 +525,13 @@ public class NEUManager { if (matchedLastQueryItem) { if (NEUDebugFlag.SEARCH.isSet()) { - NotEnoughUpdates.LOGGER.info("Found match for \"" + ANSI_YELLOW + query + ANSI_RESET + "\":\n\t" + searchDebug(splitToSearch, debugMatches)); + NotEnoughUpdates.LOGGER.info("Found match for \"" + ANSI_YELLOW + query + ANSI_RESET + "\":\n\t" + + searchDebug(splitToSearch, debugMatches)); } } else { if (NEUDebugFlag.SEARCH.isSet() && lastStringMatch != -1) { - NotEnoughUpdates.LOGGER.info("Found partial match for \"" + ANSI_YELLOW + query + ANSI_RESET + "\":\n\t" + searchDebug(splitToSearch, debugMatches)); + NotEnoughUpdates.LOGGER.info("Found partial match for \"" + ANSI_YELLOW + query + ANSI_RESET + "\":\n\t" + + searchDebug(splitToSearch, debugMatches)); } } @@ -569,12 +575,12 @@ public class NEUManager { result = result || multiSearchString(stack.getDisplayName(), sb.toString()); } - result = result || multiSearchString(stack.getDisplayName(), query); String lore = ""; - if (stack.getItem() instanceof ItemArmor && ((ItemArmor)stack.getItem()).getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER) { - lore = String.format("#%06x ",((ItemArmor)stack.getItem()).getColor(stack)); + if (stack.getItem() instanceof ItemArmor && + ((ItemArmor) stack.getItem()).getArmorMaterial() == ItemArmor.ArmorMaterial.LEATHER) { + lore = String.format("#%06x ", ((ItemArmor) stack.getItem()).getColor(stack)); } NBTTagCompound tag = stack.getTagCompound(); if (tag != null) { |
