|
1 | 1 | package parallelmc.parallelutils.commands; |
2 | 2 |
|
3 | | -import org.bukkit.ChatColor; |
| 3 | +import net.md_5.bungee.api.ChatColor; |
| 4 | +import net.md_5.bungee.api.chat.ClickEvent; |
| 5 | +import net.md_5.bungee.api.chat.ComponentBuilder; |
| 6 | +import net.md_5.bungee.api.chat.TextComponent; |
4 | 7 | import org.bukkit.command.Command; |
5 | 8 | import org.bukkit.command.CommandSender; |
6 | 9 | import org.jetbrains.annotations.NotNull; |
7 | | -import parallelmc.parallelutils.commands.ParallelCommand; |
| 10 | +import org.w3c.dom.Text; |
8 | 11 | import parallelmc.parallelutils.commands.permissions.ParallelPermission; |
9 | 12 |
|
10 | 13 | import java.util.ArrayList; |
11 | 14 | import java.util.List; |
12 | 15 |
|
| 16 | +// TODO: Make this dynamic |
13 | 17 | /** |
14 | 18 | * A command to display usages of other commands |
15 | 19 | * Usage: /pu help <page> |
@@ -55,15 +59,43 @@ public boolean execute(@NotNull CommandSender sender, @NotNull Command command, |
55 | 59 | end = HELP_MESSAGES.length; |
56 | 60 | } |
57 | 61 |
|
58 | | - StringBuilder sb = new StringBuilder(); |
59 | | - sb.append(ChatColor.YELLOW).append("--------- ").append(ChatColor.WHITE).append("Help: Index (") |
60 | | - .append(page).append("/").append(numPages).append(")") |
61 | | - .append(ChatColor.YELLOW).append(" --------------------\n").append(ChatColor.RESET); |
| 62 | + // TODO: Is there a better way to do this? It's so messy |
| 63 | + ComponentBuilder componentBuilder = new ComponentBuilder(); |
| 64 | + |
| 65 | + TextComponent smallYellow = new TextComponent("--------- "); |
| 66 | + smallYellow.setColor(net.md_5.bungee.api.ChatColor.YELLOW); |
| 67 | + |
| 68 | + TextComponent largeYellow = new TextComponent(" --------------------\n"); |
| 69 | + largeYellow.setColor(net.md_5.bungee.api.ChatColor.YELLOW); |
| 70 | + |
| 71 | + componentBuilder.append(smallYellow, ComponentBuilder.FormatRetention.NONE) |
| 72 | + .append("Help: Index (", ComponentBuilder.FormatRetention.NONE) |
| 73 | + .append("" + page).append("/").append("" + numPages).append(")") |
| 74 | + .append(largeYellow, ComponentBuilder.FormatRetention.NONE); |
62 | 75 | for (int i=start; i<end; i++) { |
63 | | - sb.append(ChatColor.GREEN).append(HELP_MESSAGES[i]).append("\n").append(ChatColor.RESET); |
| 76 | + TextComponent helpComponent = new TextComponent(HELP_MESSAGES[i]); |
| 77 | + helpComponent.setColor(net.md_5.bungee.api.ChatColor.GREEN); |
| 78 | + componentBuilder.append(helpComponent, ComponentBuilder.FormatRetention.NONE) |
| 79 | + .append("\n", ComponentBuilder.FormatRetention.NONE); |
| 80 | + } |
| 81 | + |
| 82 | + if (page != 1) { |
| 83 | + TextComponent backComponent = new TextComponent("[Back] "); |
| 84 | + backComponent.setColor(net.md_5.bungee.api.ChatColor.AQUA); |
| 85 | + backComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/pu help " + (page-1))); |
| 86 | + componentBuilder.append(backComponent); |
| 87 | + } |
| 88 | + if (page != numPages) { |
| 89 | + TextComponent backComponent = new TextComponent(" [Forward]"); |
| 90 | + backComponent.setColor(net.md_5.bungee.api.ChatColor.AQUA); |
| 91 | + backComponent.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/pu help " + (page+1))); |
| 92 | + componentBuilder.append(backComponent); |
| 93 | + TextComponent resetLocColor = new TextComponent(); |
| 94 | + resetLocColor.setColor(ChatColor.RESET); |
| 95 | + componentBuilder.append(resetLocColor, ComponentBuilder.FormatRetention.NONE); |
64 | 96 | } |
65 | 97 |
|
66 | | - sender.sendMessage(sb.toString()); |
| 98 | + sender.sendMessage(componentBuilder.create()); |
67 | 99 |
|
68 | 100 | return true; |
69 | 101 | } |
|
0 commit comments