Skip to content

Commit

Permalink
too many requests to the mojang server workaround
Browse files Browse the repository at this point in the history
too many player uuid requests are ratelimited and fail
  • Loading branch information
xyztobixyz committed Aug 16, 2014
1 parent 30b437c commit 9137c93
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions src/com/dre/managerxl/MPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -126,12 +127,48 @@ public static boolean LoadAsYml(File file) {
FileConfiguration ymlFile = YamlConfiguration.loadConfiguration(file);

Set<String> keys = ymlFile.getKeys(false);



HashMap<String, String> uuidMapping = new HashMap<String, String>();
boolean excepted = false;
ArrayList<String> uuidFails = new ArrayList<String>();
for (String uuid : keys) {
try{
UUID.fromString(uuid);
uuidMapping.put(uuid, uuid);
}catch(Exception e){
excepted = true;
P.p.log("Convert " + uuid + " to the new UUID system...");
uuidFails.add(uuid);
}
}
if(excepted){
UUIDFetcher fetcher = new UUIDFetcher(uuidFails);

try {
Map<String, UUID> result = fetcher.call();
for(String resultKey: result.keySet()){
uuidMapping.put(resultKey, result.get(resultKey).toString());
P.p.log(resultKey + " has now the UUID " + result.get(resultKey).toString());
}
} catch (Exception e) {
e.printStackTrace();
}
}




for (String uuid : keys) {
MPlayer mPlayer = null;
String uuidString = uuidMapping.get(uuid);

if(uuidString == null || uuidString.equalsIgnoreCase("null")){
continue;
}

try {
mPlayer = new MPlayer(UUID.fromString(uuid));
mPlayer = new MPlayer(UUID.fromString(uuidString));
} catch(Exception e) {
P.p.log("Convert " + uuid + " to the new UUID system...");

Expand Down Expand Up @@ -172,7 +209,9 @@ public static boolean LoadAsYml(File file) {
mPlayer.setVisible(ymlFile.getBoolean(uuid + ".isVisible"));
}
}

if(excepted){
SaveAsYml(file);
}
return true;
}

Expand Down

0 comments on commit 9137c93

Please sign in to comment.