🔎 revert match regex for searching

Took 6 minutes
This commit is contained in:
Kiran Hart 2023-08-03 20:15:09 -04:00
parent 833f1a2070
commit d42054968d
No known key found for this signature in database
GPG Key ID: 5F36C7BC79D3EBC3
3 changed files with 25 additions and 10 deletions

View File

@ -321,6 +321,21 @@ public class AuctionAPI {
return matcher.find();
}
public boolean matchSearch(String pattern, String sentence) {
Pattern patt = Pattern.compile(ChatColor.stripColor(pattern), Pattern.CASE_INSENSITIVE);
Matcher matcher = patt.matcher(sentence);
return matcher.find();
}
public boolean matchSearch(String pattern, List<String> lines) {
for (String line : lines) {
if (matchSearch(pattern, line)) {
return true;
}
}
return false;
}
/**
* @param pattern is the keyword that you're currently searching for
* @param lines is the lines being checked for the keyword

View File

@ -53,7 +53,7 @@ public final class UltraEconomyHook extends Economy {
}
if (!ultraEconomyCurrencyName[0].equalsIgnoreCase("UltraEconomy")) return;
this.currency = UltraEconomy.getAPI().getCurrencies().name(ultraEconomyCurrencyName[1]).orElse(null);
this.currency = UltraEconomy.getInstance().getCurrencies().name(ultraEconomyCurrencyName[1]).orElse(null);
if (this.currency == null) {
throw new UltraEconomyCurrencyException("AuctionHouse could not find the currency: " + ultraEconomyCurrencyName[0]);
@ -62,7 +62,7 @@ public final class UltraEconomyHook extends Economy {
@Override
public double getBalance(OfflinePlayer player) {
final Account account = UltraEconomy.getAPI().getAccounts().uuid(player.getUniqueId()).orElse(null);
final Account account = UltraEconomy.getInstance().getAccounts().uuid(player.getUniqueId()).orElse(null);
return account == null ? 0 : account.getBalance(this.currency).getSum();
}
@ -73,7 +73,7 @@ public final class UltraEconomyHook extends Economy {
@Override
public boolean withdrawBalance(OfflinePlayer player, double cost) {
final Account account = UltraEconomy.getAPI().getAccounts().uuid(player.getUniqueId()).orElse(null);
final Account account = UltraEconomy.getInstance().getAccounts().uuid(player.getUniqueId()).orElse(null);
if (account == null) return false;
account.removeBalance(this.currency, cost);
@ -82,7 +82,7 @@ public final class UltraEconomyHook extends Economy {
@Override
public boolean deposit(OfflinePlayer player, double amount) {
final Account account = UltraEconomy.getAPI().getAccounts().uuid(player.getUniqueId()).orElse(null);
final Account account = UltraEconomy.getInstance().getAccounts().uuid(player.getUniqueId()).orElse(null);
if (account == null) return false;
account.addBalance(this.currency, amount);

View File

@ -196,12 +196,12 @@ public class GUIAuctionHouse extends AbstractPlaceholderGui {
private boolean checkSearchCriteria(String phrase, AuctionedItem item) {
ItemStack stack = item.getItem();
return AuctionAPI.getInstance().match(phrase, AuctionAPI.getInstance().getItemName(stack)) ||
AuctionAPI.getInstance().match(phrase, item.getCategory().getTranslatedType()) ||
AuctionAPI.getInstance().match(phrase, stack.getType().name()) ||
AuctionAPI.getInstance().match(phrase, Bukkit.getOfflinePlayer(item.getOwner()).getName()) ||
AuctionAPI.getInstance().match(phrase, AuctionAPI.getInstance().getItemLore(stack)) ||
AuctionAPI.getInstance().match(phrase, AuctionAPI.getInstance().getItemEnchantments(stack));
return AuctionAPI.getInstance().matchSearch(phrase, AuctionAPI.getInstance().getItemName(stack)) ||
AuctionAPI.getInstance().matchSearch(phrase, item.getCategory().getTranslatedType()) ||
AuctionAPI.getInstance().matchSearch(phrase, stack.getType().name()) ||
AuctionAPI.getInstance().matchSearch(phrase, Bukkit.getOfflinePlayer(item.getOwner()).getName()) ||
AuctionAPI.getInstance().matchSearch(phrase, AuctionAPI.getInstance().getItemLore(stack)) ||
AuctionAPI.getInstance().matchSearch(phrase, AuctionAPI.getInstance().getItemEnchantments(stack));
}
/*