Skip to content

Commit

Permalink
Sort contributors within roles
Browse files Browse the repository at this point in the history
  • Loading branch information
LostLuma committed Apr 21, 2024
1 parent da857ce commit 666ced5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/terraformersmc/modmenu/util/mod/Mod.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ default String getTranslatedDescription() {
* @return a mapping of roles to each contributor with that role.
*/
@NotNull
SortedMap<String, Collection<String>> getCredits();
SortedMap<String, SortedSet<String>> getCredits();

@NotNull
Set<Badge> getBadges();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public FabricDummyParentMod(FabricMod host, String id) {
}

@Override
public @NotNull SortedMap<String, Collection<String>> getCredits() {
public @NotNull SortedMap<String, SortedSet<String>> getCredits() {
return new TreeMap<>();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,20 @@ public FabricMod(ModContainer modContainer, Set<String> modpackMods) {
}

@Override
public @NotNull SortedMap<String, Collection<String>> getCredits() {
SortedMap<String, Collection<String>> credits = new TreeMap<>();
public @NotNull SortedMap<String, SortedSet<String>> getCredits() {
SortedMap<String, SortedSet<String>> credits = new TreeMap<>();

var authors = this.getAuthors();
var contributors = this.getContributors();

if (!authors.isEmpty()) {
credits.put("Author", authors);
contributors.put("Author", authors);
}

var contributors = this.getContributors();

for (var contributor : contributors.entrySet()) {
for (var role : contributor.getValue()) {
credits.computeIfAbsent(role, key -> new ArrayList<>());
credits.get(role).add(contributor.getKey()); // Add name
credits.computeIfAbsent(role, key -> new TreeSet<>(String.CASE_INSENSITIVE_ORDER));
credits.get(role).add(contributor.getKey());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.stream.Collectors;

public class QuiltMod extends FabricMod {
Expand Down Expand Up @@ -68,15 +70,15 @@ public QuiltMod(net.fabricmc.loader.api.ModContainer fabricModContainer, Set<Str
}

@Override
public @NotNull SortedMap<String, Collection<String>> getCredits() {
SortedMap<String, Collection<String>> credits = new TreeMap<>();
public @NotNull SortedMap<String, SortedSet<String>> getCredits() {
SortedMap<String, SortedSet<String>> credits = new TreeMap<>();

var contributors = this.getContributors();

for (var contributor : contributors.entrySet()) {
for (var role : contributor.getValue()) {
credits.computeIfAbsent(role, key -> new ArrayList<>());
credits.get(role).add(contributor.getKey()); // Add name
credits.computeIfAbsent(role, key -> new TreeSet<>(String.CASE_INSENSITIVE_ORDER));
credits.get(role).add(contributor.getKey());
}
}

Expand Down

0 comments on commit 666ced5

Please sign in to comment.