Skip to content

Commit

Permalink
Remove sorting of individual contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
LostLuma committed May 1, 2024
1 parent 5963bc0 commit 0355416
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 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, SortedSet<String>> getCredits();
SortedMap<String, Set<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, SortedSet<String>> getCredits() {
public @NotNull SortedMap<String, Set<String>> getCredits() {
return new TreeMap<>();
}

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

@Override
public @NotNull Map<String, Collection<String>> getContributors() {
Map<String, Collection<String>> contributors = new HashMap<>();
Map<String, Collection<String>> contributors = new LinkedHashMap<>();

for (var contributor : this.metadata.getContributors()) {
contributors.put(contributor.getName(), List.of("Contributor"));
Expand All @@ -222,19 +222,21 @@ public FabricMod(ModContainer modContainer, Set<String> modpackMods) {
}

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

var authors = this.getAuthors();
var contributors = this.getContributors();
credits.put("Author", new LinkedHashSet<>());

for (var author : authors) {
contributors.put(author, List.of("Author"));
credits.get("Author").add(author);
}

var contributors = this.getContributors();

for (var contributor : contributors.entrySet()) {
for (var role : contributor.getValue()) {
credits.computeIfAbsent(role, key -> new TreeSet<>(String.CASE_INSENSITIVE_ORDER));
credits.computeIfAbsent(role, key -> new LinkedHashSet<>());
credits.get(role).add(contributor.getKey());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,16 @@
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
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 @@ -60,24 +59,27 @@ public QuiltMod(net.fabricmc.loader.api.ModContainer fabricModContainer, Set<Str

@Override
public @NotNull Map<String, Collection<String>> getContributors() {
Map<String, Collection<String>> contributors = new HashMap<>();
Map<String, Collection<String>> contributors = new LinkedHashMap<>();

for (var contributor : this.metadata.contributors()) {
contributors.put(contributor.name(), contributor.roles());
// For Fabric mods a contributor may appear twice
// If they are both an Author and Contributor ...
contributors.computeIfAbsent(contributor.name(), name -> new HashSet<>());
contributors.get(contributor.name()).addAll(contributor.roles());
}

return contributors;
}

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

var contributors = this.getContributors();

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

0 comments on commit 0355416

Please sign in to comment.