Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

Sign up now!
RuneMate will permanently shut down on August 7, 2026
due to events outside our control. You can continue using RuneMate until this date after which it will no longer be available. Thank you to everyone that contributed to RuneMate's success and to the community for the opportunity to serve you all these years.

  • Learn about RuneMate Vault and how its zero knowledge local encryption already protects your sensitive information.
  • Edit or delete your RuneMate account from your Account Settings.
  • All account upgrade subscriptions have been cancelled. No action required.

Resolved Detection of items with brackets in name fails

Author of MaxiBots
Joined
Dec 3, 2013
Messages
7,468
Inventory.newQuery().names("Guam potion (unf)").results().first() returns null
Inventory.newQuery().names("Guam potion \\(unf\\)").results().first() finds the correct item

@Cloud
 
Joined
Dec 10, 2014
Messages
3,377
Seems like the names(String...) is converting the Strings to Patterns but doesn't escape the brackets :/

Edit: Which means this might be occurring in the other queries as well
 
Engineer
Joined
Jul 28, 2013
Messages
2,776
For the next release, does this check out to you?
Code:
public static Pattern getPatternForExactString(final String string) {
String pattern = "^";
for (char c : string.toCharArray()) {
if (c == '(' || c == ')' || c == '^' || c == '$'|| c == '.' || c == '*' || c == '?' || c == '|'|| c == '[' || c == '{') {
pattern += "\\";
}
pattern += c;
}
pattern += "$";
return Pattern.compile(pattern);
}
 
Joined
Dec 10, 2014
Messages
3,377
For the next release, does this check out to you?
Code:
public static Pattern getPatternForExactString(final String string) {
String pattern = "^";
for (char c : string.toCharArray()) {
if (c == '(' || c == ')' || c == '^' || c == '$'|| c == '.' || c == '*' || c == '?' || c == '|'|| c == '[' || c == '{') {
pattern += "\\";
}
pattern += c;
}
pattern += "$";
return Pattern.compile(pattern);
}
What about the closing braces and brackets?
 
Discretion is advised
Joined
Jan 2, 2014
Messages
306
You could use IDs instead of names anyway since SpriteItem IDs dont change
 
Top