mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-11-28 05:35:26 +01:00
Swap slow get method
This commit is contained in:
parent
d626c08b4c
commit
9fde237d9b
@ -30,7 +30,6 @@ import me.lucko.luckperms.exceptions.ObjectAlreadyHasException;
|
||||
import me.lucko.luckperms.utils.AbstractManager;
|
||||
import me.lucko.luckperms.utils.Identifiable;
|
||||
|
||||
import java.util.NoSuchElementException;
|
||||
import java.util.UUID;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@ -44,14 +43,13 @@ public abstract class UserManager extends AbstractManager<UserIdentifier, User>
|
||||
*/
|
||||
@SuppressWarnings("OptionalGetWithoutIsPresent")
|
||||
public User get(String name) {
|
||||
try {
|
||||
return getAll().values().stream()
|
||||
.filter(u -> u.getName().equalsIgnoreCase(name))
|
||||
.limit(1).findAny().get();
|
||||
} catch (NoSuchElementException e) {
|
||||
return null;
|
||||
for (User user : getAll().values()) {
|
||||
if (user.getName().equalsIgnoreCase(name)) {
|
||||
return user;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public User get(UUID uuid) {
|
||||
return get(UserIdentifier.of(uuid, null));
|
||||
|
Loading…
Reference in New Issue
Block a user