From 5e00490e67d6ff2b3711a5b2a39348273a653374 Mon Sep 17 00:00:00 2001 From: LostLuma Date: Wed, 1 May 2024 09:22:59 +0200 Subject: [PATCH] Preserve order of mod authors on Fabric --- .../com/terraformersmc/modmenu/util/mod/Mod.java | 2 +- .../util/mod/fabric/FabricDummyParentMod.java | 2 +- .../modmenu/util/mod/fabric/FabricMod.java | 14 ++++++++------ .../modmenu/util/mod/quilt/QuiltMod.java | 6 ++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/terraformersmc/modmenu/util/mod/Mod.java b/src/main/java/com/terraformersmc/modmenu/util/mod/Mod.java index 268b3a08..877df022 100644 --- a/src/main/java/com/terraformersmc/modmenu/util/mod/Mod.java +++ b/src/main/java/com/terraformersmc/modmenu/util/mod/Mod.java @@ -78,7 +78,7 @@ default String getTranslatedDescription() { * @return a mapping of roles to each contributor with that role. */ @NotNull - SortedMap> getCredits(); + SortedMap> getCredits(); @NotNull Set getBadges(); diff --git a/src/main/java/com/terraformersmc/modmenu/util/mod/fabric/FabricDummyParentMod.java b/src/main/java/com/terraformersmc/modmenu/util/mod/fabric/FabricDummyParentMod.java index 39e3ac26..e3c1e7d3 100644 --- a/src/main/java/com/terraformersmc/modmenu/util/mod/fabric/FabricDummyParentMod.java +++ b/src/main/java/com/terraformersmc/modmenu/util/mod/fabric/FabricDummyParentMod.java @@ -94,7 +94,7 @@ public FabricDummyParentMod(FabricMod host, String id) { } @Override - public @NotNull SortedMap> getCredits() { + public @NotNull SortedMap> getCredits() { return new TreeMap<>(); } diff --git a/src/main/java/com/terraformersmc/modmenu/util/mod/fabric/FabricMod.java b/src/main/java/com/terraformersmc/modmenu/util/mod/fabric/FabricMod.java index 2c89e9e5..5f5dab0e 100644 --- a/src/main/java/com/terraformersmc/modmenu/util/mod/fabric/FabricMod.java +++ b/src/main/java/com/terraformersmc/modmenu/util/mod/fabric/FabricMod.java @@ -212,7 +212,7 @@ public FabricMod(ModContainer modContainer, Set modpackMods) { @Override public @NotNull Map> getContributors() { - Map> contributors = new HashMap<>(); + Map> contributors = new LinkedHashMap<>(); for (var contributor : this.metadata.getContributors()) { contributors.put(contributor.getName(), List.of("Contributor")); @@ -222,19 +222,21 @@ public FabricMod(ModContainer modContainer, Set modpackMods) { } @Override - public @NotNull SortedMap> getCredits() { - SortedMap> credits = new TreeMap<>(); + public @NotNull SortedMap> getCredits() { + SortedMap> 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()); } } diff --git a/src/main/java/com/terraformersmc/modmenu/util/mod/quilt/QuiltMod.java b/src/main/java/com/terraformersmc/modmenu/util/mod/quilt/QuiltMod.java index ae69ba2e..c8569d7e 100644 --- a/src/main/java/com/terraformersmc/modmenu/util/mod/quilt/QuiltMod.java +++ b/src/main/java/com/terraformersmc/modmenu/util/mod/quilt/QuiltMod.java @@ -15,7 +15,6 @@ 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.List; @@ -23,7 +22,6 @@ 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; @@ -70,8 +68,8 @@ public QuiltMod(net.fabricmc.loader.api.ModContainer fabricModContainer, Set> getCredits() { - SortedMap> credits = new TreeMap<>(); + public @NotNull SortedMap> getCredits() { + SortedMap> credits = new TreeMap<>(); var contributors = this.getContributors();