From efed3fda23d95ed172508523f68e2e2016deb721 Mon Sep 17 00:00:00 2001 From: DarkKronicle Date: Mon, 11 Apr 2022 15:51:39 -0600 Subject: [PATCH] Updating methods --- .../advancedchatcore/util/SearchResult.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/io/github/darkkronicle/advancedchatcore/util/SearchResult.java b/src/main/java/io/github/darkkronicle/advancedchatcore/util/SearchResult.java index 9980e58..7865c18 100644 --- a/src/main/java/io/github/darkkronicle/advancedchatcore/util/SearchResult.java +++ b/src/main/java/io/github/darkkronicle/advancedchatcore/util/SearchResult.java @@ -16,6 +16,7 @@ import lombok.Getter; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; +import net.minecraft.text.Text; /** An object that holds information about a search. */ @Environment(EnvType.CLIENT) @@ -126,4 +127,18 @@ public static SearchResult searchOf(String input, String match, FindType type) { List matches = finder.getMatches(input, match); return new SearchResult(input, match, finder, matches); } + + /** + * A method to construct a SearchResult based off of an input, condition, and {@link FindType} + * + * @param input Input string to match from + * @param match Search text + * @param type {@link FindType} way to search + * @return SearchResult with compiled searches + */ + public static SearchResult searchOf(Text input, String match, FindType type) { + IFinder finder = type.getFinder(); + List matches = finder.getMatches(input, match); + return new SearchResult(input.getString(), match, finder, matches); + } }