From 57cb509cbaa14c448d32dfa3bf18a063f8c5d77f Mon Sep 17 00:00:00 2001 From: Lilly Rose Berner Date: Sat, 15 Jun 2024 10:58:59 -0400 Subject: [PATCH] Remove sorting of individual contributors (#726) - Fixed contributors being sorted --- .../com/terraformersmc/modmenu/util/mod/Mod.java | 2 +- .../util/mod/fabric/FabricDummyParentMod.java | 2 +- .../modmenu/util/mod/fabric/FabricMod.java | 8 ++++---- .../modmenu/util/mod/quilt/QuiltMod.java | 15 +++++++-------- 4 files changed, 13 insertions(+), 14 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 48ff9428..d05237f6 100644 --- a/src/main/java/com/terraformersmc/modmenu/util/mod/Mod.java +++ b/src/main/java/com/terraformersmc/modmenu/util/mod/Mod.java @@ -84,7 +84,7 @@ default Text getFormattedDescription() { /** * @return a mapping of roles to each contributor with that role. */ - @NotNull SortedMap> getCredits(); + @NotNull 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 6f998201..ad9197a9 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 @@ -214,7 +214,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")); @@ -224,8 +224,8 @@ 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(); @@ -236,7 +236,7 @@ public FabricMod(ModContainer modContainer, Set modpackMods) { 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..de7a2a63 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,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 { @@ -60,7 +59,7 @@ public QuiltMod(net.fabricmc.loader.api.ModContainer fabricModContainer, Set> getContributors() { - Map> contributors = new HashMap<>(); + Map> contributors = new LinkedHashMap<>(); for (var contributor : this.metadata.contributors()) { contributors.put(contributor.name(), contributor.roles()); @@ -70,14 +69,14 @@ 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(); 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()); } }