add a log message the first time a username lookup fails

This commit is contained in:
Xander committed 2017-07-21 21:24:12 +08:00
1 parent a39d624545
commit 7bf8fedb37
1 file changed
+7 -1
@@ -113,6 +113,8 @@ public final class MekanismUtils
public static final Map<String, Class<?>> classesFound = new HashMap<String, Class<?>>();
private static final List<UUID> warnedFails = new ArrayList<>();
/**
* Checks for a new version of Mekanism.
*/
@@ -1513,12 +1515,16 @@ public final class MekanismUtils
public static String getLastKnownUsername(UUID uuid)
{
String ret = UsernameCache.getLastKnownUsername(uuid);
if (ret == null && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ // see if MC/Yggdrasil knows about it?!
if (ret == null && !warnedFails.contains(uuid) && FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER){ // see if MC/Yggdrasil knows about it?!
GameProfile gp = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerProfileCache().getProfileByUUID(uuid);
if (gp != null){
ret = gp.getName();
}
}
if (ret == null && !warnedFails.contains(uuid)){
Mekanism.logger.warn("Failed to retrieve username for UUID {}, you might want to add it to the JSON cache", uuid);
warnedFails.add(uuid);
}
return ret != null ? ret : "<???>";
}