From 6b9fde4c370cddd93c9a66fbcdb7bd1dddf2cde8 Mon Sep 17 00:00:00 2001 From: deirn Date: Mon, 17 Jun 2024 22:38:40 +0700 Subject: [PATCH] sort plugin id on plugin toggle screen (cherry picked from commit 38adb5f34207d8604cf89959eef11594ad600589) --- .../mobius/waila/gui/screen/PluginToggleScreen.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/mcp/mobius/waila/gui/screen/PluginToggleScreen.java b/src/main/java/mcp/mobius/waila/gui/screen/PluginToggleScreen.java index 270d7cd56..b4d162a5f 100644 --- a/src/main/java/mcp/mobius/waila/gui/screen/PluginToggleScreen.java +++ b/src/main/java/mcp/mobius/waila/gui/screen/PluginToggleScreen.java @@ -2,6 +2,7 @@ import it.unimi.dsi.fastutil.objects.Object2BooleanOpenHashMap; import mcp.mobius.waila.api.IWailaConfig; +import mcp.mobius.waila.api.WailaConstants; import mcp.mobius.waila.buildconst.Tl; import mcp.mobius.waila.gui.widget.ConfigListWidget; import mcp.mobius.waila.gui.widget.value.BooleanValue; @@ -50,7 +51,17 @@ public ConfigListWidget getOptions() { }); - for (var plugin : PluginInfo.getAll()) { + var sorted = PluginInfo.getAll().stream().sorted((a, b) -> { + var aId = a.getPluginId(); + var bId = b.getPluginId(); + + var aIsWaila = aId.getNamespace().equals(WailaConstants.NAMESPACE); + var bIsWaila = bId.getNamespace().equals(WailaConstants.NAMESPACE); + if (aIsWaila == bIsWaila) return aId.compareTo(bId); + return aIsWaila ? +1 : -1; + }).toList(); + + for (var plugin : sorted) { var impl = (PluginInfo) plugin; var id = plugin.getPluginId(); var enabled = plugin.isEnabled();