mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2025-02-27 09:51:30 +01:00
parent
57e104256b
commit
c5ba4b1fea
@ -95,6 +95,12 @@ public void init() {
|
||||
.executes(this::statusCommand)
|
||||
.build();
|
||||
|
||||
LiteralCommandNode<S> helpCommand =
|
||||
literal("help")
|
||||
.requires(requirementsUnloaded("bluemap.help"))
|
||||
.executes(this::helpCommand)
|
||||
.build();
|
||||
|
||||
LiteralCommandNode<S> reloadCommand =
|
||||
literal("reload")
|
||||
.requires(requirementsUnloaded("bluemap.reload"))
|
||||
@ -216,6 +222,7 @@ public void init() {
|
||||
|
||||
// command tree
|
||||
dispatcher.getRoot().addChild(baseCommand);
|
||||
baseCommand.addChild(helpCommand);
|
||||
baseCommand.addChild(reloadCommand);
|
||||
baseCommand.addChild(debugCommand);
|
||||
baseCommand.addChild(pauseCommand);
|
||||
@ -304,6 +311,34 @@ public int statusCommand(CommandContext<S> context) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int helpCommand(CommandContext<S> context) {
|
||||
CommandSource source = commandSourceInterface.apply(context.getSource());
|
||||
|
||||
source.sendMessage(Text.of(TextColor.BLUE, "BlueMap Commands:"));
|
||||
for (String usage : dispatcher.getAllUsage(dispatcher.getRoot().getChild("bluemap"), context.getSource(), true)) {
|
||||
Text usageText = Text.of(TextColor.GREEN, "/bluemap");
|
||||
|
||||
String[] arguments = usage.split(" ");
|
||||
for (String arg : arguments) {
|
||||
if (arg.isEmpty()) continue;
|
||||
if (arg.charAt(0) == '<' && arg.charAt(arg.length() - 1) == '>') {
|
||||
usageText.addChild(Text.of(TextColor.GRAY, " " + arg));
|
||||
} else {
|
||||
usageText.addChild(Text.of(TextColor.WHITE, " " + arg));
|
||||
}
|
||||
}
|
||||
|
||||
source.sendMessage(usageText);
|
||||
}
|
||||
|
||||
source.sendMessage(
|
||||
Text.of(TextColor.BLUE, "\nOpen this link to get a description for each command:\n")
|
||||
.addChild(Text.of(TextColor.GRAY, "https://bluecolo.red/bluemap-commands").setClickLink("https://bluecolo.red/bluemap-commands"))
|
||||
);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
public int reloadCommand(CommandContext<S> context) {
|
||||
CommandSource source = commandSourceInterface.apply(context.getSource());
|
||||
|
||||
|
@ -36,6 +36,7 @@ public class Text {
|
||||
private Set<TextFormat> formats = new HashSet<>();
|
||||
private Text hoverText;
|
||||
private String clickCommand;
|
||||
private String clickLink;
|
||||
private List<Text> children = new ArrayList<>();
|
||||
|
||||
public Text setHoverText(Text hoverText) {
|
||||
@ -50,6 +51,12 @@ public Text setClickCommand(String clickCommand) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Text setClickLink(String clickLink) {
|
||||
this.clickLink = clickLink;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Text addChild(Text child) {
|
||||
children.add(child);
|
||||
|
||||
@ -82,6 +89,13 @@ public String toJSONString() {
|
||||
sb.append(quote("action")).append(":").append(quote("run_command")).append(',');
|
||||
sb.append(quote("value")).append(":").append(quote(clickCommand));
|
||||
sb.append("},");
|
||||
}
|
||||
|
||||
else if (clickLink != null) {
|
||||
sb.append(quote("clickEvent")).append(":{");
|
||||
sb.append(quote("action")).append(":").append(quote("open_url")).append(',');
|
||||
sb.append(quote("value")).append(":").append(quote(clickLink));
|
||||
sb.append("},");
|
||||
}
|
||||
|
||||
if (!children.isEmpty()) {
|
||||
|
@ -10,6 +10,7 @@ permissions:
|
||||
bluemap.*:
|
||||
children:
|
||||
bluemap.status: true
|
||||
bluemap.help: true
|
||||
bluemap.reload: true
|
||||
bluemap.pause: true
|
||||
bluemap.resume: true
|
||||
@ -19,6 +20,8 @@ permissions:
|
||||
default: op
|
||||
bluemap.status:
|
||||
default: op
|
||||
bluemap.help:
|
||||
default: op
|
||||
bluemap.reload:
|
||||
default: op
|
||||
bluemap.pause:
|
||||
|
Loading…
Reference in New Issue
Block a user