Skip to content

Commit 0f704aa

Browse files
committed
Updated: Make commands in parent help clickable
1 parent 9bd0e1f commit 0f704aa

File tree

1 file changed

+11
-1
lines changed
  • modules/RoyalCommands/src/main/java/org/royaldev/royalcommands/rcommands

1 file changed

+11
-1
lines changed

modules/RoyalCommands/src/main/java/org/royaldev/royalcommands/rcommands/ParentCommand.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
import org.royaldev.royalcommands.RUtils;
1313
import org.royaldev.royalcommands.RoyalCommands;
1414

15+
import net.md_5.bungee.api.chat.ClickEvent;
16+
import net.md_5.bungee.api.chat.TextComponent;
17+
1518
import java.util.ArrayList;
1619
import java.util.List;
1720

@@ -98,7 +101,14 @@ public void showHelp(final CommandSender cs, final String label) {
98101
cs.sendMessage(sb.toString());
99102
for (final SubCommand sc : this.subcommands) {
100103
if (!this.isAuthorized(cs, sc)) continue;
101-
cs.sendMessage(" " + MessageColor.POSITIVE + "/" + label + " " + sc.getUsage().replace("<command>", sc.getShortName()));
104+
String cmdPrefix = "/" + label + " " + sc.getUsage().replace("<command>", sc.getShortName());
105+
TextComponent tt = new TextComponent(" ");
106+
TextComponent cmd = new TextComponent(cmdPrefix);
107+
cmd.setColor(MessageColor.POSITIVE.bc());
108+
// cmd.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new Text("Click to ")));
109+
cmd.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, cmdPrefix.split("[\\(\\[\\{]")[0]));
110+
tt.addExtra(cmd);
111+
cs.spigot().sendMessage(tt);
102112
cs.sendMessage(" " + MessageColor.NEUTRAL + sc.getDescription());
103113
}
104114
}

0 commit comments

Comments
 (0)