From 8eb35b7935bb0f23362db4b13965d67774c3904c Mon Sep 17 00:00:00 2001 From: Kiran Hart Date: Fri, 9 Jun 2023 16:34:05 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A8=20adjust=20match=20regex=20to=20no?= =?UTF-8?q?t=20be=20stupid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Took 3 minutes --- src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java b/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java index b8fa347..cdaccca 100644 --- a/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java +++ b/src/main/java/ca/tweetzy/auctionhouse/api/AuctionAPI.java @@ -264,7 +264,8 @@ public class AuctionAPI { */ public String getItemName(ItemStack stack) { Objects.requireNonNull(stack, "Item stack cannot be null when getting name"); - return stack.getItemMeta().hasDisplayName() ? stack.getItemMeta().getDisplayName() : TextUtils.formatText("&f" + WordUtils.capitalize(stack.getType().name().toLowerCase().replace("_", " "))); + final String name = stack.getItemMeta().hasDisplayName() ? stack.getItemMeta().getDisplayName() : TextUtils.formatText("&f" + WordUtils.capitalize(stack.getType().name().toLowerCase().replace("_", " "))); + return name; } /** @@ -313,7 +314,8 @@ public class AuctionAPI { * @return whether the keyword is found */ public boolean match(String pattern, String sentence) { - Pattern patt = Pattern.compile(ChatColor.stripColor(pattern), Pattern.CASE_INSENSITIVE); +// Pattern patt = Pattern.compile(ChatColor.stripColor(pattern), Pattern.CASE_INSENSITIVE); + Pattern patt = Pattern.compile("\\b" + Pattern.quote(ChatColor.stripColor(pattern)) + "\\b", Pattern.CASE_INSENSITIVE); Matcher matcher = patt.matcher(sentence); return matcher.find(); }