From 0b6f326c18f561b8f4007d3016b584d50c0ebbe9 Mon Sep 17 00:00:00 2001 From: Luck Date: Tue, 7 Mar 2017 22:17:49 +0000 Subject: [PATCH] Fallback to uuid in the search command if the username is unknown --- .../luckperms/common/commands/misc/SearchCommand.java | 4 ++-- .../me/lucko/luckperms/common/commands/utils/Util.java | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/misc/SearchCommand.java b/common/src/main/java/me/lucko/luckperms/common/commands/misc/SearchCommand.java index 70a45065..6fe7c30e 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/misc/SearchCommand.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/misc/SearchCommand.java @@ -72,8 +72,8 @@ public class SearchCommand extends SingleCommand { Map uuidLookups = new HashMap<>(); Function lookupFunc = uuid -> uuidLookups.computeIfAbsent(uuid, u -> { String s = plugin.getStorage().getName(u).join(); - if (s == null) { - s = "null"; + if (s == null || s.isEmpty() || s.equals("null")) { + s = u.toString(); } return s; }); diff --git a/common/src/main/java/me/lucko/luckperms/common/commands/utils/Util.java b/common/src/main/java/me/lucko/luckperms/common/commands/utils/Util.java index 3b87579d..82a81c5c 100644 --- a/common/src/main/java/me/lucko/luckperms/common/commands/utils/Util.java +++ b/common/src/main/java/me/lucko/luckperms/common/commands/utils/Util.java @@ -281,13 +281,15 @@ public class Util { int index = pageNumber - 1; List>> pages = divideList(sorted, 15); - if ((index < 0 || index >= pages.size())) { + if (index < 0 || index >= pages.size()) { pageNumber = 1; index = 0; } List> page = pages.get(index); - List>> uuidMappedPage = page.stream().map(hp -> Maps.immutableEntry(uuidLookup.apply(hp.getHolder()), hp)).collect(Collectors.toList()); + List>> uuidMappedPage = page.stream() + .map(hp -> Maps.immutableEntry(uuidLookup.apply(hp.getHolder()), hp)) + .collect(Collectors.toList()); FancyMessage message = new FancyMessage(""); String title = "&7(page &f" + pageNumber + "&7 of &f" + pages.size() + "&7 - &f" + sorted.size() + "&7 entries)"; @@ -316,7 +318,7 @@ public class Util { int index = pageNumber - 1; List>> pages = divideList(sorted, 15); - if ((index < 0 || index >= pages.size())) { + if (index < 0 || index >= pages.size()) { pageNumber = 1; index = 0; }