Fix OfflinePlayerUUIDService breaking when no worlds have been loaded.

This commit is contained in:
Alexander Söderberg 2020-06-24 08:05:06 +02:00
parent e17222dd19
commit 159b35c717
No known key found for this signature in database
GPG key ID: C0207FF7EA146678

View file

@ -44,15 +44,19 @@ import java.util.UUID;
public class OfflinePlayerUUIDService implements UUIDService {
@Override @NotNull public List<UUIDMapping> getNames(@NotNull final List<UUID> uuids) {
if (Settings.UUID.FORCE_LOWERCASE) {
if (Settings.UUID.FORCE_LOWERCASE || Bukkit.getWorlds().isEmpty()) {
return Collections.emptyList(); // This is useless now
}
final List<UUIDMapping> wrappers = new ArrayList<>(uuids.size());
for (final UUID uuid : uuids) {
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(uuid);
try {
if (offlinePlayer.hasPlayedBefore()) {
wrappers.add(new UUIDMapping(uuid, offlinePlayer.getName()));
}
} catch (final Exception ignored) {} /* This can be safely ignored. If this happens, it is
probably because it's called before the worlds have
been loaded. This is bad, but does not break anything */
}
return wrappers;
}