Skip to content

Command

TimmyOVO edited this page May 1, 2020 · 2 revisions

Command

A quick example

        MainCommandSpec.newBuilder()
                .addAlias("test")
                .addAlias("t")
                .withDescription("test command")
                .withCommandSpecExecutor((commandSender, args) -> {
                    commandSender.sendMessage("test command execute");
                    return true;
                })
                .childCommandSpec(SubCommandSpec.newBuilder()
                        .addAlias("arg1")
                        .addAlias("a1")
                        .withDescription("test arg1")
                        .withPermission("permission")
                        .childCommandSpec(SubCommandSpec.newBuilder()
                                .addAlias("aarg2")
                                .addAlias("aa2")
                                .withDescription("test aarg2")
                                .withPermission("permission")
                                .childCommandSpec(SubCommandSpec.newBuilder()
                                        .addAlias("aarg3")
                                        .addAlias("aa3")
                                        .childCommandSpec(SubCommandSpec.newBuilder()
                                                .addAlias("aarg4")
                                                .addAlias("aa4")
                                                .childCommandSpec(SubCommandSpec.newBuilder()
                                                        .addAlias("aarg5")
                                                        .addAlias("aa5")
                                                        .withCommandSpecExecutor((commandSender, args) -> {
                                                            commandSender.sendMessage("test aargs5");
                                                            return true;
                                                        })
                                                        .build())
                                                .withCommandSpecExecutor((commandSender, args) -> {
                                                    commandSender.sendMessage("test aargs4");
                                                    return true;
                                                })
                                                .build())
                                        .withCommandSpecExecutor((commandSender, args) -> {
                                            commandSender.sendMessage("test aargs3");
                                            return true;
                                        })
                                        .build())
                                .withCommandSpecExecutor((commandSender, args) -> {
                                    commandSender.sendMessage("test aargs2");
                                    return true;
                                })
                                .build())
                        .childCommandSpec(SubCommandSpec.newBuilder()
                                .addAlias("arg2")
                                .addAlias("a2")
                                .withDescription("test arg2")
                                .withPermission("permission")
                                .childCommandSpec(SubCommandSpec.newBuilder()
                                        .addAlias("arg3")
                                        .addAlias("a3")
                                        .childCommandSpec(SubCommandSpec.newBuilder()
                                                .addAlias("arg4")
                                                .addAlias("a4")
                                                .childCommandSpec(SubCommandSpec.newBuilder()
                                                        .addAlias("arg5")
                                                        .addAlias("a5")
                                                        .withCommandSpecExecutor((commandSender, args) -> {
                                                            commandSender.sendMessage("test args5");
                                                            return true;
                                                        })
                                                        .build())
                                                .withCommandSpecExecutor((commandSender, args) -> {
                                                    commandSender.sendMessage("test args4");
                                                    return true;
                                                })
                                                .build())
                                        .withCommandSpecExecutor((commandSender, args) -> {
                                            commandSender.sendMessage("test args3");
                                            return true;
                                        })
                                        .build())
                                .withCommandSpecExecutor((commandSender, args) -> {
                                    commandSender.sendMessage("test args2");
                                    return true;
                                })
                                .build())
                        .withCommandSpecExecutor((commandSender, args) -> {
                            commandSender.sendMessage("test args1");
                            return true;
                        })
                        .build())
                .build()
                .register();
Clone this wiki locally