mirror of
https://github.com/JonasunderscoreJones/ZtereoMUSIC.git
synced 2025-10-25 13:39:19 +02:00
Defer Regex compilation to initialization
This commit is contained in:
parent
d31d36538e
commit
3df3a069c8
1 changed files with 2 additions and 3 deletions
|
|
@ -24,6 +24,7 @@ import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
public class Play implements Command {
|
public class Play implements Command {
|
||||||
|
private static final Pattern URL_PATTERN = Pattern.compile("^(http|https)://([a-z]+\\.[a-z]+)+/\\S+$", Pattern.CASE_INSENSITIVE);
|
||||||
CommandMeta meta = new CommandMeta("play", "Play music!", new String[]{"p"}, false, false);
|
CommandMeta meta = new CommandMeta("play", "Play music!", new String[]{"p"}, false, false);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -52,9 +53,7 @@ public class Play implements Command {
|
||||||
|
|
||||||
// check if args merged are/have url, if so try to feed it into lava, else try to youtube api the fuck out of it.
|
// check if args merged are/have url, if so try to feed it into lava, else try to youtube api the fuck out of it.
|
||||||
String mergedArgs = String.join(" ", args);
|
String mergedArgs = String.join(" ", args);
|
||||||
|
Matcher matchedUrls = URL_PATTERN.matcher(mergedArgs);
|
||||||
Pattern urlPattern = Pattern.compile("^(http|https)://([a-z]+\\.[a-z]+)+/\\S+$", Pattern.CASE_INSENSITIVE);
|
|
||||||
Matcher matchedUrls = urlPattern.matcher(mergedArgs);
|
|
||||||
boolean urlFound = matchedUrls.find();
|
boolean urlFound = matchedUrls.find();
|
||||||
|
|
||||||
String identifier;
|
String identifier;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue