From a64c70d13151745938b5a2bff1da4a97eeb7344d Mon Sep 17 00:00:00 2001 From: Reflxction Dev Date: Fri, 22 Apr 2022 16:35:01 +0300 Subject: [PATCH] Make commands and categories implement Comparable --- .../main/java/revxrsal/commands/command/CommandCategory.java | 2 +- .../java/revxrsal/commands/command/ExecutableCommand.java | 3 ++- .../main/java/revxrsal/commands/core/BaseCommandCategory.java | 3 +++ .../main/java/revxrsal/commands/core/CommandExecutable.java | 4 ++++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/revxrsal/commands/command/CommandCategory.java b/common/src/main/java/revxrsal/commands/command/CommandCategory.java index b0d4716b..5f82e9a9 100644 --- a/common/src/main/java/revxrsal/commands/command/CommandCategory.java +++ b/common/src/main/java/revxrsal/commands/command/CommandCategory.java @@ -20,7 +20,7 @@ *
  • Subactions, such as {@link Default}.
  • * */ -public interface CommandCategory extends PermissionHolder { +public interface CommandCategory extends PermissionHolder, Comparable { /** * Returns the name of this category diff --git a/common/src/main/java/revxrsal/commands/command/ExecutableCommand.java b/common/src/main/java/revxrsal/commands/command/ExecutableCommand.java index db59da4a..13733055 100644 --- a/common/src/main/java/revxrsal/commands/command/ExecutableCommand.java +++ b/common/src/main/java/revxrsal/commands/command/ExecutableCommand.java @@ -13,6 +13,7 @@ import revxrsal.commands.core.CommandPath; import revxrsal.commands.process.ResponseHandler; +import java.util.Comparator; import java.util.List; import java.util.Map; @@ -20,7 +21,7 @@ * Represents a command which can be executed with specific arguments, * flags or switches. */ -public interface ExecutableCommand extends CommandAnnotationHolder, PermissionHolder { +public interface ExecutableCommand extends CommandAnnotationHolder, PermissionHolder, Comparable { /** * Returns the name of the command diff --git a/common/src/main/java/revxrsal/commands/core/BaseCommandCategory.java b/common/src/main/java/revxrsal/commands/core/BaseCommandCategory.java index 7eb4b23d..26de0670 100644 --- a/common/src/main/java/revxrsal/commands/core/BaseCommandCategory.java +++ b/common/src/main/java/revxrsal/commands/core/BaseCommandCategory.java @@ -101,4 +101,7 @@ private class CategoryPermission implements CommandPermission { } } + @Override public int compareTo(@NotNull CommandCategory o) { + return path.compareTo(o.getPath()); + } } diff --git a/common/src/main/java/revxrsal/commands/core/CommandExecutable.java b/common/src/main/java/revxrsal/commands/core/CommandExecutable.java index f3549fa0..45b14795 100644 --- a/common/src/main/java/revxrsal/commands/core/CommandExecutable.java +++ b/common/src/main/java/revxrsal/commands/core/CommandExecutable.java @@ -115,4 +115,8 @@ public void setPermission(@NotNull CommandPermission permission) { ", name='" + name + '\'' + '}'; } + + @Override public int compareTo(@NotNull ExecutableCommand o) { + return path.compareTo(o.getPath()); + } }