Skip to content

Commit

Permalink
Make commands and categories implement Comparable
Browse files Browse the repository at this point in the history
  • Loading branch information
Revxrsal committed Apr 22, 2022
1 parent 8fe6d51 commit a64c70d
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
* <li>Subactions, such as {@link Default}.</li>
* </ul>
*/
public interface CommandCategory extends PermissionHolder {
public interface CommandCategory extends PermissionHolder, Comparable<CommandCategory> {

/**
* Returns the name of this category
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
import revxrsal.commands.core.CommandPath;
import revxrsal.commands.process.ResponseHandler;

import java.util.Comparator;
import java.util.List;
import java.util.Map;

/**
* 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<ExecutableCommand> {

/**
* Returns the name of the command
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,4 +101,7 @@ private class CategoryPermission implements CommandPermission {
}
}

@Override public int compareTo(@NotNull CommandCategory o) {
return path.compareTo(o.getPath());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,8 @@ public void setPermission(@NotNull CommandPermission permission) {
", name='" + name + '\'' +
'}';
}

@Override public int compareTo(@NotNull ExecutableCommand o) {
return path.compareTo(o.getPath());
}
}

0 comments on commit a64c70d

Please sign in to comment.