From 2c940ecdac9a9c677fa7f3c53d7c717b6e3088bb Mon Sep 17 00:00:00 2001 From: riking Date: Wed, 26 Nov 2014 01:52:17 -0800 Subject: [PATCH] Try again later when Mojang ratelimits us --- .../runnables/database/UUIDUpdateAsyncTask.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java index 98a582ccd..c37bfc70c 100644 --- a/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java +++ b/src/main/java/com/gmail/nossr50/runnables/database/UUIDUpdateAsyncTask.java @@ -68,6 +68,17 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { fetchedUUIDs.putAll(new UUIDFetcher(userNamesSection).call()); } catch (Exception e) { + // Handle 429 + if (e.getMessage().contains("429")) { + try { + Thread.sleep(LIMIT_PERIOD); + } catch (InterruptedException ex) { + e.printStackTrace(); + return; + } + continue; + } + plugin.getLogger().log(Level.SEVERE, "Unable to fetch UUIDs!", e); return; } @@ -77,7 +88,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable { size = userNames.size(); Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis); - if (fetchedUUIDs.size() > BATCH_SIZE) { + if (fetchedUUIDs.size() >= BATCH_SIZE) { mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs); fetchedUUIDs = new HashMap(); }