mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 22:27:32 +00:00
Update GuiNPCAbilities.java
This commit is contained in:
1 parent
eda8931b5f
commit
3beaf68815
1 file changed
+24
-1
@@ -491,8 +491,31 @@ public class GuiNPCAbilities extends GuiNPCInterface2 implements IScrollData, IC
|
||||
for (int i = 0; i < npcSlots.size(); i++) {
|
||||
list.add(getAbilityListEntry(i));
|
||||
}
|
||||
|
||||
// Sort: enabled first, then numerically by slot index
|
||||
Collections.sort(list, new Comparator<String>() {
|
||||
@Override
|
||||
public int compare(String a, String b) {
|
||||
boolean aEnabled = a.startsWith("\u00A7a");
|
||||
boolean bEnabled = b.startsWith("\u00A7a");
|
||||
if (aEnabled != bEnabled) return aEnabled ? -1 : 1;
|
||||
return extractIndex(a) - extractIndex(b);
|
||||
}
|
||||
|
||||
private int extractIndex(String entry) {
|
||||
String stripped = entry.replaceAll("\u00A7.", "").trim();
|
||||
int dotIndex = stripped.indexOf(".");
|
||||
if (dotIndex > 0) {
|
||||
try {
|
||||
return Integer.parseInt(stripped.substring(0, dotIndex).replaceAll("[^0-9]", ""));
|
||||
} catch (NumberFormatException e) { }
|
||||
}
|
||||
return Integer.MAX_VALUE;
|
||||
}
|
||||
});
|
||||
|
||||
if (npcAbilitiesScroll != null) {
|
||||
npcAbilitiesScroll.setList(list);
|
||||
npcAbilitiesScroll.setUnsortedList(list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user