|
10 | 10 | import java.util.ArrayList; |
11 | 11 |
|
12 | 12 | import net.wurstclient.DontBlock; |
| 13 | +import net.wurstclient.WurstClient; |
13 | 14 | import net.wurstclient.command.CmdException; |
14 | 15 | import net.wurstclient.command.CmdSyntaxError; |
15 | 16 | import net.wurstclient.command.Command; |
@@ -57,21 +58,45 @@ private void listCommands(int page) throws CmdException |
57 | 58 | int start = (page - 1) * CMDS_PER_PAGE; |
58 | 59 | int end = Math.min(page * CMDS_PER_PAGE, cmds.size()); |
59 | 60 |
|
| 61 | + String prefix = "."; |
| 62 | + try |
| 63 | + { |
| 64 | + prefix = WurstClient.INSTANCE.getOtfs().commandPrefixOtf |
| 65 | + .getPrefixSetting().getSelected().toString(); |
| 66 | + }catch(Throwable ignored) |
| 67 | + {} |
| 68 | + |
60 | 69 | ChatUtils.message("Command list (page " + page + "/" + pages + ")"); |
61 | 70 | for(int i = start; i < end; i++) |
62 | | - ChatUtils.message("- " + cmds.get(i).getName()); |
| 71 | + { |
| 72 | + String name = cmds.get(i).getName(); |
| 73 | + if(name.startsWith(".")) |
| 74 | + name = name.substring(1); |
| 75 | + ChatUtils.message("- " + prefix + name); |
| 76 | + } |
63 | 77 | } |
64 | 78 |
|
65 | 79 | private void help(String cmdName) throws CmdException |
66 | 80 | { |
67 | | - if(cmdName.startsWith(".")) |
68 | | - cmdName = cmdName.substring(1); |
| 81 | + String prefix = "."; |
| 82 | + try |
| 83 | + { |
| 84 | + prefix = WurstClient.INSTANCE.getOtfs().commandPrefixOtf |
| 85 | + .getPrefixSetting().getSelected().toString(); |
| 86 | + }catch(Throwable ignored) |
| 87 | + {} |
| 88 | + |
| 89 | + if(cmdName.startsWith(prefix)) |
| 90 | + cmdName = cmdName.substring(prefix.length()); |
69 | 91 |
|
70 | 92 | Command cmd = WURST.getCmds().getCmdByName(cmdName); |
71 | 93 | if(cmd == null) |
72 | | - throw new CmdSyntaxError("Unknown command: ." + cmdName); |
| 94 | + throw new CmdSyntaxError("Unknown command: " + prefix + cmdName); |
| 95 | + |
| 96 | + ChatUtils.message("Available help for " + prefix + cmdName + ":"); |
73 | 97 |
|
74 | | - ChatUtils.message("Available help for ." + cmdName + ":"); |
75 | | - cmd.printHelp(); |
| 98 | + String desc = cmd.getDescription().replaceAll("\\.(?=\\w)", prefix); |
| 99 | + for(String line : desc.split("\n")) |
| 100 | + ChatUtils.message(line); |
76 | 101 | } |
77 | 102 | } |
0 commit comments