1
0
mirror of https://e.coding.net/circlecloud/YumCore.git synced 2024-12-27 07:28:52 +00:00

feat: 添加根据命令名称排序

Signed-off-by: 502647092 <admin@yumc.pw>
This commit is contained in:
502647092 2016-11-11 16:35:56 +08:00
parent 56a6b0137b
commit 8914c7c12f

View File

@ -1,15 +1,14 @@
package pw.yumc.YumCore.commands; package pw.yumc.YumCore.commands;
import java.util.*;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import pw.yumc.YumCore.bukkit.P; import pw.yumc.YumCore.bukkit.P;
import pw.yumc.YumCore.commands.annotation.Help; import pw.yumc.YumCore.commands.annotation.Help;
import pw.yumc.YumCore.commands.info.CommandInfo; import pw.yumc.YumCore.commands.info.CommandInfo;
import pw.yumc.YumCore.commands.interfaces.CommandHelpParse; import pw.yumc.YumCore.commands.interfaces.CommandHelpParse;
import java.util.*;
/** /**
* 命令帮助生成类 * 命令帮助生成类
* *
@ -72,6 +71,7 @@ public class CommandHelp {
public CommandHelp(CommandInfo defCmd, Collection<? extends CommandInfo> list) { public CommandHelp(CommandInfo defCmd, Collection<? extends CommandInfo> list) {
this.defCmd = defCmd; this.defCmd = defCmd;
cmdlist = new LinkedList<>(list); cmdlist = new LinkedList<>(list);
Collections.sort(cmdlist, new CommandNameComparator());
Collections.sort(cmdlist, new CommandComparator()); Collections.sort(cmdlist, new CommandComparator());
HELPPAGECOUNT = (int) Math.ceil((double) cmdlist.size() / LINES_PER_PAGE); HELPPAGECOUNT = (int) Math.ceil((double) cmdlist.size() / LINES_PER_PAGE);
} }
@ -167,6 +167,19 @@ public class CommandHelp {
this.helpParse = helpParse; this.helpParse = helpParse;
} }
/**
* 命令名称比较器
*
* @since 2016年7月23日 下午4:17:18
* @author
*/
static class CommandNameComparator implements Comparator<CommandInfo> {
@Override
public int compare(CommandInfo o1, CommandInfo o2) {
return o1.getName().compareTo(o2.getName());
}
}
/** /**
* 命令排序比较器 * 命令排序比较器
* *