diff --git a/src/main/java/net/frozenorb/apiv3/model/User.java b/src/main/java/net/frozenorb/apiv3/model/User.java index 88612cd..0b7dd5f 100644 --- a/src/main/java/net/frozenorb/apiv3/model/User.java +++ b/src/main/java/net/frozenorb/apiv3/model/User.java @@ -611,17 +611,12 @@ public final class User { return ImmutableList.of(Rank.findById("default")); } - Iterator iterator = grantedRanks.iterator(); - Set copiedRanks = ImmutableSet.copyOf(grantedRanks); - // This is to remove redundant ranks. Say they have mod, mod-plus, admin, and youtuber, // we should remove mod and mod-plus as it'll be made redundant by the higher ranked admin. - while (iterator.hasNext()) { - Rank rank = iterator.next(); - + for (Rank grantedRank : ImmutableSet.copyOf(grantedRanks)) { // Check all other ranks for inherited collision - for (Rank otherRank : copiedRanks) { - if (otherRank == rank) { + for (Rank otherRank : ImmutableSet.copyOf(grantedRanks)) { + if (grantedRank == otherRank) { continue; } @@ -629,8 +624,8 @@ public final class User { // Iterate up the inheritance tree to detect rank redundancies. while (parent.getInheritsFromId() != null) { - if (parent == rank) { - iterator.remove(); + if (parent == grantedRank) { + grantedRanks.remove(grantedRank); } parent = Rank.findById(parent.getInheritsFromId());