From 5a5c01153f0efd25a8711324be707ce884d754ff Mon Sep 17 00:00:00 2001 From: 502647092 Date: Mon, 19 Sep 2016 17:05:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=80=E8=88=AC?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 502647092 --- src/main/java/pw/yumc/YumCore/commands/CommandHelp.java | 9 +++++---- src/main/java/pw/yumc/YumCore/commands/CommandInfo.java | 2 +- .../java/pw/yumc/YumCore/commands/CommandManager.java | 8 ++++---- src/main/java/pw/yumc/YumCore/commands/TabInfo.java | 3 ++- .../YumCore/commands/exception/CommandException.java | 4 ++++ 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/main/java/pw/yumc/YumCore/commands/CommandHelp.java b/src/main/java/pw/yumc/YumCore/commands/CommandHelp.java index 3db41d8..de4f3c3 100644 --- a/src/main/java/pw/yumc/YumCore/commands/CommandHelp.java +++ b/src/main/java/pw/yumc/YumCore/commands/CommandHelp.java @@ -31,6 +31,10 @@ public class CommandHelp { private final static String helpTitle = String.format("§6========= %s §6插件帮助列表=========", prefix); private final static String helpBody = "§6/%1$s §a%2$s §e%3$s §6- §b%4$s"; private final static String helpFooter = "§6查看更多的帮助页面 §b请输入 /%s help §e1-%s"; + /** + * 帮助页面每页行数 + */ + private final static int LINES_PER_PAGE = 7; /** * 默认命令 */ @@ -47,10 +51,6 @@ public class CommandHelp { * 帮助页面数量 */ private final int HELPPAGECOUNT; - /** - * 帮助页面每页行数 - */ - private final int LINES_PER_PAGE = 7; /** * 帮助列表缓存 */ @@ -133,6 +133,7 @@ public class CommandHelp { page = Integer.parseInt(args[1]); page = page == 0 ? 1 : page; } catch (final Exception e) { + // Ignore } final String helpkey = label + page; if (!cacheHelp.containsKey(helpkey)) { diff --git a/src/main/java/pw/yumc/YumCore/commands/CommandInfo.java b/src/main/java/pw/yumc/YumCore/commands/CommandInfo.java index eceee23..6dc4977 100644 --- a/src/main/java/pw/yumc/YumCore/commands/CommandInfo.java +++ b/src/main/java/pw/yumc/YumCore/commands/CommandInfo.java @@ -234,7 +234,7 @@ public class CommandInfo { } private String eS(final List executors) { - final StringBuffer str = new StringBuffer(); + final StringBuilder str = new StringBuilder(); for (final Executor executor : executors) { str.append(executor.getName()); str.append(", "); diff --git a/src/main/java/pw/yumc/YumCore/commands/CommandManager.java b/src/main/java/pw/yumc/YumCore/commands/CommandManager.java index 1fb7065..1284732 100644 --- a/src/main/java/pw/yumc/YumCore/commands/CommandManager.java +++ b/src/main/java/pw/yumc/YumCore/commands/CommandManager.java @@ -29,12 +29,12 @@ import pw.yumc.YumCore.bukkit.compatible.C; * @author 喵♂呜 */ public class CommandManager implements TabExecutor { - private final String argumentTypeError = "注解命令方法 %s 位于 %s 的参数错误 应只有 CommandArgument 参数!"; - private final String returnTypeError = "注解命令补全 %s 位于 %s 的返回值错误 应实现 List 接口!"; + private final static String argumentTypeError = "注解命令方法 %s 位于 %s 的参数错误 应只有 CommandArgument 参数!"; + private final static String returnTypeError = "注解命令补全 %s 位于 %s 的返回值错误 应实现 List 接口!"; /** * 插件实例类 */ - private final JavaPlugin plugin = P.instance; + private final static JavaPlugin plugin = P.instance; /** * 默认命令 */ @@ -207,7 +207,7 @@ public class CommandManager implements TabExecutor { private List getPlayerTabComplete(final CommandSender sender, final Command command, final String alias, final String[] args) { final String lastWord = args[args.length - 1]; final Player senderPlayer = sender instanceof Player ? (Player) sender : null; - final ArrayList matchedPlayers = new ArrayList<>(); + final List matchedPlayers = new ArrayList<>(); for (final Player player : C.Player.getOnlinePlayers()) { final String name = player.getName(); if ((senderPlayer == null || senderPlayer.canSee(player)) && StringUtil.startsWithIgnoreCase(name, lastWord)) { diff --git a/src/main/java/pw/yumc/YumCore/commands/TabInfo.java b/src/main/java/pw/yumc/YumCore/commands/TabInfo.java index 7e8da3e..0f6bd82 100644 --- a/src/main/java/pw/yumc/YumCore/commands/TabInfo.java +++ b/src/main/java/pw/yumc/YumCore/commands/TabInfo.java @@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender; import pw.yumc.YumCore.bukkit.P; import pw.yumc.YumCore.commands.annotation.Tab; +import pw.yumc.YumCore.commands.exception.CommandException; /** * Tab补全 @@ -72,7 +73,7 @@ public class TabInfo { try { return (List) method.invoke(origin, cmdArgs); } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { - throw new RuntimeException("调用Tab自动补全发生错误 请反馈给开发者 " + Arrays.toString(P.instance.getDescription().getAuthors().toArray()) + " !", e); + throw new CommandException("调用Tab自动补全发生错误 请反馈给开发者 " + Arrays.toString(P.instance.getDescription().getAuthors().toArray()) + " !", e); } } diff --git a/src/main/java/pw/yumc/YumCore/commands/exception/CommandException.java b/src/main/java/pw/yumc/YumCore/commands/exception/CommandException.java index 6593c79..b0f3792 100644 --- a/src/main/java/pw/yumc/YumCore/commands/exception/CommandException.java +++ b/src/main/java/pw/yumc/YumCore/commands/exception/CommandException.java @@ -16,4 +16,8 @@ public class CommandException extends RuntimeException { super(string); } + public CommandException(final String string, final Exception e) { + super(string, e); + } + }