Use the servers uuid cache in the output to /lp search if LP doesn't have data (#974)
This commit is contained in:
+12
-3
@@ -40,6 +40,7 @@ import me.lucko.luckperms.common.command.access.ArgumentPermissions;
|
||||
import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
@@ -96,10 +97,18 @@ public class GroupListMembers extends SubCommand<Group> {
|
||||
LoadingCache<UUID, String> uuidLookups = Caffeine.newBuilder()
|
||||
.build(u -> {
|
||||
String s = plugin.getStorage().getPlayerName(u).join();
|
||||
if (s == null || s.isEmpty() || s.equals("null")) {
|
||||
s = u.toString();
|
||||
if (s != null && !s.isEmpty() && !s.equals("null")) {
|
||||
return s;
|
||||
}
|
||||
return s;
|
||||
|
||||
if (plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUID_CACHE)) {
|
||||
s = plugin.getBootstrap().lookupUsername(u).orElse(null);
|
||||
if (s != null) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
return u.toString();
|
||||
});
|
||||
sendResult(sender, matchedUsers, uuidLookups::get, Message.SEARCH_SHOWING_USERS, HolderType.USER, label, page);
|
||||
}
|
||||
|
||||
@@ -41,6 +41,7 @@ import me.lucko.luckperms.common.command.access.CommandPermission;
|
||||
import me.lucko.luckperms.common.command.utils.ArgumentParser;
|
||||
import me.lucko.luckperms.common.command.utils.MessageUtils;
|
||||
import me.lucko.luckperms.common.command.utils.TabCompletions;
|
||||
import me.lucko.luckperms.common.config.ConfigKeys;
|
||||
import me.lucko.luckperms.common.locale.LocaleManager;
|
||||
import me.lucko.luckperms.common.locale.command.CommandSpec;
|
||||
import me.lucko.luckperms.common.locale.message.Message;
|
||||
@@ -97,10 +98,18 @@ public class SearchCommand extends SingleCommand {
|
||||
LoadingCache<UUID, String> uuidLookups = Caffeine.newBuilder()
|
||||
.build(u -> {
|
||||
String s = plugin.getStorage().getPlayerName(u).join();
|
||||
if (s == null || s.isEmpty() || s.equals("null")) {
|
||||
s = u.toString();
|
||||
if (s != null && !s.isEmpty() && !s.equals("null")) {
|
||||
return s;
|
||||
}
|
||||
return s;
|
||||
|
||||
if (plugin.getConfiguration().get(ConfigKeys.USE_SERVER_UUID_CACHE)) {
|
||||
s = plugin.getBootstrap().lookupUsername(u).orElse(null);
|
||||
if (s != null) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
return u.toString();
|
||||
});
|
||||
sendResult(sender, matchedUsers, uuidLookups::get, Message.SEARCH_SHOWING_USERS, HolderType.USER, label, page, comparison);
|
||||
}
|
||||
|
||||
+8
@@ -168,6 +168,14 @@ public interface LuckPermsBootstrap {
|
||||
*/
|
||||
Optional<UUID> lookupUuid(String username);
|
||||
|
||||
/**
|
||||
* Lookup a username from a uuid, using the servers internal uuid cache.
|
||||
*
|
||||
* @param uuid the uuid to lookup
|
||||
* @return an optional username, if found
|
||||
*/
|
||||
Optional<String> lookupUsername(UUID uuid);
|
||||
|
||||
/**
|
||||
* Gets the number of users online on the platform
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user