From a1651e896f2e8a61e8b49b0ed065d524ba0f43d3 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Tue, 30 Mar 2021 12:03:48 +0200 Subject: [PATCH] Sort SWCommand.commandSet by subCommand length Sort SWCommand.commandHelpSet by subCommand length --- SpigotCore_Main/src/de/steamwar/command/SWCommand.java | 3 +++ SpigotCore_Main/src/de/steamwar/command/SubCommand.java | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java index 70e7443..3aa9668 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SWCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SWCommand.java @@ -131,6 +131,9 @@ public abstract class SWCommand { } commandSet.add(new SubCommand(this, method, anno.value())); }); + + commandSet.sort(Comparator.comparingInt(o -> -o.subCommand.length)); + commandHelpSet.sort(Comparator.comparingInt(o -> -o.subCommand.length)); } } diff --git a/SpigotCore_Main/src/de/steamwar/command/SubCommand.java b/SpigotCore_Main/src/de/steamwar/command/SubCommand.java index 7838108..f299359 100644 --- a/SpigotCore_Main/src/de/steamwar/command/SubCommand.java +++ b/SpigotCore_Main/src/de/steamwar/command/SubCommand.java @@ -19,7 +19,6 @@ package de.steamwar.command; -import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import java.lang.reflect.InvocationTargetException; @@ -27,13 +26,12 @@ import java.lang.reflect.Method; import java.lang.reflect.Parameter; import java.util.*; import java.util.function.Function; -import java.util.logging.Level; class SubCommand { private SWCommand swCommand; private Method method; - private String[] subCommand; + String[] subCommand; private TypeMapper[] arguments; private boolean varArgs = false; private Function commandSenderFunction;