From 78985f15deb9e5fbc55c104d5bff5750a97781f4 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 14 May 2021 21:03:55 +0200 Subject: [PATCH] Fix SWCommand help list sorting --- SpigotCore_Main/src/de/steamwar/command/SWCommand.java | 10 +++++++++- .../src/de/steamwar/command/SubCommand.java | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java index ff920b7..0df0148 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java @@ -125,7 +125,15 @@ public abstract class SWCommand { o2.varArgType != null ? Integer.MAX_VALUE : o2.arguments.length); } }); - commandHelpList.sort(Comparator.comparingInt(o -> -o.subCommand.length)); + commandHelpList.sort((o1, o2) -> { + int compare = Integer.compare(-o1.subCommand.length, -o2.subCommand.length); + if (compare != 0) { + return compare; + } else { + return Integer.compare(o1.method.getDeclaringClass() == SWCommand.class ? 0 : 1, + o2.method.getDeclaringClass() == SWCommand.class ? 0 : 1); + } + }); } } diff --git a/SpigotCore_Main/src/de/steamwar/command/SubCommand.java b/SpigotCore_Main/src/de/steamwar/command/SubCommand.java index d530b1a..0ea3852 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SubCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SubCommand.java @@ -33,7 +33,7 @@ import static de.steamwar.command.SWCommandUtils.*; class SubCommand { private SWCommand swCommand; - private Method method; + Method method; String description; Parameter[] parameters; String[] subCommand;