diff --git a/src/com/dre/managerxl/MPlayer.java b/src/com/dre/managerxl/MPlayer.java index 15e7ba8..f1cb25f 100644 --- a/src/com/dre/managerxl/MPlayer.java +++ b/src/com/dre/managerxl/MPlayer.java @@ -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; @@ -126,12 +127,48 @@ public static boolean LoadAsYml(File file) { FileConfiguration ymlFile = YamlConfiguration.loadConfiguration(file); Set keys = ymlFile.getKeys(false); - + + + HashMap uuidMapping = new HashMap(); + boolean excepted = false; + ArrayList uuidFails = new ArrayList(); + 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 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..."); @@ -172,7 +209,9 @@ public static boolean LoadAsYml(File file) { mPlayer.setVisible(ymlFile.getBoolean(uuid + ".isVisible")); } } - + if(excepted){ + SaveAsYml(file); + } return true; }