feat: Add worldedit.schematic.list.other permission and functionality (#1507)

* Add worldedit.schematic.list.other permission and functionality

* Implement StringMan#containsUuid

* Javadocs

* chore: Add since annotation

Co-authored-by: NotMyFault <mc.cache@web.de>
This commit is contained in:
Owen1212055
2022-01-05 10:21:44 -05:00
committed by GitHub
parent f4658cc668
commit c27a34ce40
2 changed files with 36 additions and 0 deletions

View File

@@ -9,11 +9,14 @@ import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
public class StringMan {
private static final Pattern UUID_PATTERN = Pattern.compile("[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}");
public static boolean containsAny(CharSequence sequence, String any) {
return IntStream.range(0, sequence.length())
.anyMatch(i -> any.indexOf(sequence.charAt(i)) != -1);
@@ -542,4 +545,16 @@ public class StringMan {
return IntStream.range(0, n).mapToObj(i -> s).collect(Collectors.joining());
}
/**
* Returns if there is a valid uuid contained inside the
* provided String.
*
* @param str provided string
* @return true if an uuid was found, false if not
* @since 2.0.0
*/
public static boolean containsUuid(String str) {
return UUID_PATTERN.matcher(str).find();
}
}