From b36c6427d1e32d0382d01326114b8d1e9bdf3f44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexander=20S=C3=B6derberg?= Date: Thu, 9 Jul 2020 20:25:16 +0200 Subject: [PATCH] Split failed UUID batches into individual requests in order to identify the invalid UUIDs --- .../bukkit/uuid/SquirrelIdUUIDService.java | 26 +++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SquirrelIdUUIDService.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SquirrelIdUUIDService.java index 4580519aa..8c8dfca83 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SquirrelIdUUIDService.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SquirrelIdUUIDService.java @@ -26,6 +26,8 @@ package com.plotsquared.bukkit.uuid; import com.google.common.util.concurrent.RateLimiter; +import com.plotsquared.core.PlotSquared; +import com.plotsquared.core.configuration.Captions; import com.plotsquared.core.uuid.UUIDMapping; import com.plotsquared.core.uuid.UUIDService; import com.sk89q.squirrelid.Profile; @@ -35,6 +37,7 @@ import org.jetbrains.annotations.NotNull; import java.io.IOException; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.UUID; @@ -65,8 +68,27 @@ public class SquirrelIdUUIDService implements UUIDService { final List results = new ArrayList<>(uuids.size()); this.rateLimiter.acquire(uuids.size()); try { - for (final Profile profile : this.profileService.findAllById(uuids)) { - results.add(new UUIDMapping(profile.getUniqueId(), profile.getName())); + try { + for (final Profile profile : this.profileService.findAllById(uuids)) { + results.add(new UUIDMapping(profile.getUniqueId(), profile.getName())); + } + } catch (final IllegalArgumentException illegalArgumentException) { + // + // This means that the UUID was invalid for whatever reason, we'll try to + // go through them one by one + // + if (uuids.size() >= 2) { + PlotSquared.debug(Captions.PREFIX + "(UUID) Found invalid UUID in batch. Will try each UUID individually."); + for (final UUID uuid : uuids) { + final List result = this.getNames(Collections.singletonList(uuid)); + if (result.isEmpty()) { + continue; + } + results.add(result.get(0)); + } + } else if (uuids.size() == 1) { + PlotSquared.debug(Captions.PREFIX + "(UUID) Found invalid UUID: " + uuids.get(0)); + } } } catch (IOException | InterruptedException e) { e.printStackTrace();