@@ -111,6 +111,7 @@ public boolean isValidUser() {
111111 * Prefers returning the name of their account on steam, if they have one
112112 */
113113 public String getDisplayName () {
114+ getJE ();
114115 if (displayName == null ) {
115116 displayName = getJE ().get ("displayName" ).getAsString ();
116117 }
@@ -276,43 +277,46 @@ public void requestToJoinClan(Clan clan) {
276277 * it will select the first profile in the profiles array
277278 */
278279 public JsonObject getJE () {
279- if (intendedPlatform != -2 ) {
280- for (JsonElement jsonElement : getJO ().getAsJsonArray ("profiles" )) {
281- if (jsonElement .getAsJsonObject ().get ("membershipType" ).getAsInt () == intendedPlatform ) {
282- je = jsonElement .getAsJsonObject ();
283- return je ;
280+ if (je == null ) {
281+ if (intendedPlatform != -2 ) {
282+ for (JsonElement jsonElement : getJO ().getAsJsonArray ("profiles" )) {
283+ if (jsonElement .getAsJsonObject ().get ("membershipType" ).getAsInt () == intendedPlatform ) {
284+ je = jsonElement .getAsJsonObject ();
285+ return je ;
286+ }
284287 }
285- }
286288
287- // Some users may have cross saved a console account to their pc account
288- for (JsonElement jsonElement : getJO ().getAsJsonArray ("profilesWithErrors" )) {
289- if (jsonElement .getAsJsonObject ().getAsJsonObject ("infoCard" ).get ("membershipType" ).getAsInt () == intendedPlatform ) {
290- JsonObject temp = jsonElement .getAsJsonObject ().getAsJsonObject ("infoCard" );
291- displayName = temp .get ("displayName" ).getAsString ();
292- isPublic = temp .get ("isPublic" ).getAsBoolean ();
293- crossSaveOverride = temp .get ("crossSaveOverride" ).getAsInt ();
294-
295- // If a user has a profileWithErrors we have to get most info from a profile that is not in error
296- for (JsonElement jsonElement1 : getJO ().getAsJsonArray ("profiles" )) {
297- // Does the main profile have the intended platform in its applicablemembershipTypes?
298- for (JsonElement jsonElement2 : jsonElement1 .getAsJsonObject ().getAsJsonArray ("applicableMembershipTypes" )) {
299- if (jsonElement2 .getAsInt () == intendedPlatform ) {
300- je = jsonElement1 .getAsJsonObject ();
301- return je ;
289+ // Some users may have cross saved a console account to their pc account
290+ for (JsonElement jsonElement : getJO ().getAsJsonArray ("profilesWithErrors" )) {
291+ if (jsonElement .getAsJsonObject ().getAsJsonObject ("infoCard" ).get ("membershipType" ).getAsInt () == intendedPlatform ) {
292+ JsonObject temp = jsonElement .getAsJsonObject ().getAsJsonObject ("infoCard" );
293+ displayName = temp .get ("displayName" ).getAsString ();
294+ isPublic = temp .get ("isPublic" ).getAsBoolean ();
295+ crossSaveOverride = temp .get ("crossSaveOverride" ).getAsInt ();
296+
297+ // If a user has a profileWithErrors we have to get most info from a profile that is not in error
298+ for (JsonElement jsonElement1 : getJO ().getAsJsonArray ("profiles" )) {
299+ // Does the main profile have the intended platform in its applicablemembershipTypes?
300+ for (JsonElement jsonElement2 : jsonElement1 .getAsJsonObject ().getAsJsonArray ("applicableMembershipTypes" )) {
301+ if (jsonElement2 .getAsInt () == intendedPlatform ) {
302+ je = jsonElement1 .getAsJsonObject ();
303+ return je ;
304+ }
302305 }
303306 }
304307 }
305308 }
306- }
307309
310+ }
311+ je = getJO ().get ("profiles" ).getAsJsonArray ().get (0 ).getAsJsonObject ();
308312 }
309- je = getJO ().get ("profiles" ).getAsJsonArray ().get (0 ).getAsJsonObject ();
310313
311314
312315 return je ;
313316 }
314317
315318 public void setIntendedPlatform (DestinyPlatform destinyPlatform ) {
316319 intendedPlatform = destinyPlatform .getPlatformCode ();
320+ je = null ;
317321 }
318322}
0 commit comments