Use the servers uuid cache in the output to /lp search if LP doesn't have data (#974)

This commit is contained in:
Luck
2018-05-06 16:20:08 +01:00
Unverified
parent d3dded8791
commit 91b7af52ac
8 changed files with 76 additions and 14 deletions
@@ -182,6 +182,19 @@ public class LPBungeeBootstrap extends Plugin implements LuckPermsBootstrap {
return Optional.empty();
}
@Override
public Optional<String> lookupUsername(UUID uuid) {
if (getProxy().getPluginManager().getPlugin("RedisBungee") != null) {
try {
return RedisBungeeUtil.lookupUsername(uuid);
} catch (Throwable t) {
t.printStackTrace();
}
}
return Optional.empty();
}
@Override
public int getPlayerCount() {
return getProxy().getOnlineCount();
@@ -39,7 +39,11 @@ public final class RedisBungeeUtil {
* @return a uuid, if present
*/
public static Optional<UUID> lookupUuid(String username) {
return Optional.ofNullable(RedisBungee.getApi()).flatMap(a -> Optional.ofNullable(a.getUuidFromName(username, true)));
return Optional.ofNullable(RedisBungee.getApi()).map(a -> a.getUuidFromName(username, true));
}
public static Optional<String> lookupUsername(UUID uuid) {
return Optional.ofNullable(RedisBungee.getApi()).map(a -> a.getNameFromUuid(uuid, true));
}
private RedisBungeeUtil() {}