Browse Source

Try again later when Mojang ratelimits us

riking 10 years ago
parent
commit
2c940ecdac

+ 12 - 1
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());
                 fetchedUUIDs.putAll(new UUIDFetcher(userNamesSection).call());
             }
             }
             catch (Exception e) {
             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);
                 plugin.getLogger().log(Level.SEVERE, "Unable to fetch UUIDs!", e);
                 return;
                 return;
             }
             }
@@ -77,7 +88,7 @@ public class UUIDUpdateAsyncTask extends BukkitRunnable {
             size = userNames.size();
             size = userNames.size();
 
 
             Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis);
             Misc.printProgress(checkedUsers, DatabaseManager.progressInterval, startMillis);
-            if (fetchedUUIDs.size() > BATCH_SIZE) {
+            if (fetchedUUIDs.size() >= BATCH_SIZE) {
                 mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs);
                 mcMMO.getDatabaseManager().saveUserUUIDs(fetchedUUIDs);
                 fetchedUUIDs = new HashMap<String, UUID>();
                 fetchedUUIDs = new HashMap<String, UUID>();
             }
             }