mirror of
https://github.com/EngineHub/WorldGuard.git
synced 2024-10-07 02:57:28 +02:00
Make UUID detection in DomainInputResolver reusable.
This commit is contained in:
parent
501a7aa77a
commit
e43ce420a3
@ -99,10 +99,11 @@ public DefaultDomain call() throws UnresolvedNamesException {
|
||||
if (m.matches()) {
|
||||
domain.addGroup(m.group(1));
|
||||
} else {
|
||||
try {
|
||||
UUID uuid = parseUUID(s);
|
||||
if (uuid != null) {
|
||||
// Try to add any UUIDs given
|
||||
domain.addPlayer(UUID.fromString(UUIDs.addDashes(s.replaceAll("^uuid:", ""))));
|
||||
} catch (IllegalArgumentException e) {
|
||||
} else {
|
||||
switch (locatorPolicy) {
|
||||
case NAME_ONLY:
|
||||
domain.addPlayer(s);
|
||||
@ -157,4 +158,21 @@ public DefaultDomain apply(@Nullable DefaultDomain domain) {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to parse a UUID locator from input.
|
||||
*
|
||||
* @param input the input
|
||||
* @return a UUID or {@code null} if the input is not a UUID
|
||||
*/
|
||||
@Nullable
|
||||
public static UUID parseUUID(String input) {
|
||||
checkNotNull(input);
|
||||
|
||||
try {
|
||||
return UUID.fromString(UUIDs.addDashes(input.replaceAll("^uuid:", "")));
|
||||
} catch (IllegalArgumentException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user