Skip to content

Commit

Permalink
Modules: Preserve order of modules for dependency requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
camnwalter authored and mattco98 committed Jul 4, 2024
1 parent a6881fd commit 8fe1550
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.function.Supplier;
Expand All @@ -22,7 +23,7 @@ public abstract class SystemDetailsMixin {
@Inject(method = "<init>", at = @At("RETURN"))
private void addModules(CallbackInfo ci) {
addSection("ChatTriggers Modules", () -> {
List<Module> modules = ModuleManager.INSTANCE.getCachedModules();
List<Module> modules = new ArrayList<>(ModuleManager.INSTANCE.getCachedModules());
modules.sort(Comparator.comparing(Module::getName));

StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,6 @@ object ModuleUpdater : Initializer {
}

cachedModules.add(module)
cachedModules.sortWith { a, b ->
a.name.compareTo(b.name)
}
return listOf(module) + (module.metadata.requires?.map {
importModule(it, module.name)
}?.flatten() ?: emptyList())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ object ModulesGui : UScreen(unlocalizedName = "Modules") {
window.exit.draw((middle + width / 2f - 17) / 2f, (window.scroll + 99f) / 2f)

window.height = 125f
ModuleManager.cachedModules.forEach {
ModuleManager.cachedModules.sortedBy { it.name }.forEach {
window.height += it.draw(middle - width / 2f, window.scroll + window.height, width)
}

Expand Down

0 comments on commit 8fe1550

Please sign in to comment.