mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 17:57:38 +00:00
Sort commands for Dispatchers in CommandUsageBox.
This commit is contained in:
parent
2effc57b78
commit
7c2f6f0bcc
@ -20,14 +20,18 @@
|
|||||||
package com.sk89q.worldedit.util.formatting.components;
|
package com.sk89q.worldedit.util.formatting.components;
|
||||||
|
|
||||||
import com.sk89q.minecraft.util.commands.CommandLocals;
|
import com.sk89q.minecraft.util.commands.CommandLocals;
|
||||||
|
import com.sk89q.worldedit.extension.platform.CommandManager;
|
||||||
import com.sk89q.worldedit.util.command.CommandCallable;
|
import com.sk89q.worldedit.util.command.CommandCallable;
|
||||||
import com.sk89q.worldedit.util.command.CommandMapping;
|
import com.sk89q.worldedit.util.command.CommandMapping;
|
||||||
import com.sk89q.worldedit.util.command.Description;
|
import com.sk89q.worldedit.util.command.Description;
|
||||||
import com.sk89q.worldedit.util.command.Dispatcher;
|
import com.sk89q.worldedit.util.command.Dispatcher;
|
||||||
import com.sk89q.worldedit.util.formatting.Style;
|
import com.sk89q.worldedit.util.command.PrimaryAliasComparator;
|
||||||
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
import com.sk89q.worldedit.util.formatting.StyledFragment;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
@ -66,7 +70,11 @@ public class CommandUsageBox extends StyledFragment {
|
|||||||
private void attachDispatcherUsage(Dispatcher dispatcher, String commandString, @Nullable CommandLocals locals) {
|
private void attachDispatcherUsage(Dispatcher dispatcher, String commandString, @Nullable CommandLocals locals) {
|
||||||
CommandListBox box = new CommandListBox("Subcommands");
|
CommandListBox box = new CommandListBox("Subcommands");
|
||||||
String prefix = !commandString.isEmpty() ? commandString + " " : "";
|
String prefix = !commandString.isEmpty() ? commandString + " " : "";
|
||||||
for (CommandMapping mapping : dispatcher.getCommands()) {
|
|
||||||
|
List<CommandMapping> list = new ArrayList<CommandMapping>(dispatcher.getCommands());
|
||||||
|
Collections.sort(list, new PrimaryAliasComparator(CommandManager.COMMAND_CLEAN_PATTERN));
|
||||||
|
|
||||||
|
for (CommandMapping mapping : list) {
|
||||||
if (locals == null || mapping.getCallable().testPermission(locals)) {
|
if (locals == null || mapping.getCallable().testPermission(locals)) {
|
||||||
box.appendCommand(prefix + mapping.getPrimaryAlias(), mapping.getDescription().getShortDescription());
|
box.appendCommand(prefix + mapping.getPrimaryAlias(), mapping.getDescription().getShortDescription());
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user