当前位置: 首页>>代码示例>>Java>>正文


Java CommandCallable类代码示例

本文整理汇总了Java中org.spongepowered.api.command.CommandCallable的典型用法代码示例。如果您正苦于以下问题:Java CommandCallable类的具体用法?Java CommandCallable怎么用?Java CommandCallable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CommandCallable类属于org.spongepowered.api.command包,在下文中一共展示了CommandCallable类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCommand

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
/**
 * Build a complete command hierarchy
 * @return
 */
public static CommandSpec getCommand() {
    ImmutableMap.Builder<List<String>, CommandCallable> builder = ImmutableMap.builder();
    builder.put(ImmutableList.of("pos", "position"), PositionCommand.getCommand());
    builder.put(ImmutableList.of("zone", "z"), ZoneCommands.getCommand());
    builder.put(ImmutableList.of("reload"), ReloadCommand.getCommand());
    builder.put(ImmutableList.of("?", "help"), HelpCommand.getCommand());

    return CommandSpec.builder()
    .executor((src, args) -> {
        src.sendMessage(Text.of(
            Format.heading(TextColors.GRAY, "By ", TextColors.GOLD, "viveleroi.\n"),
            TextColors.GRAY, "Help: ", TextColors.WHITE, "/sg ?\n",
            TextColors.GRAY, "IRC: ", TextColors.WHITE, "irc.esper.net #helion3\n"
        ));
        return CommandResult.empty();
    })
    .children(builder.build()).build();
}
 
开发者ID:prism,项目名称:SafeGuard,代码行数:23,代码来源:SafeGuardCommands.java

示例2: execute

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
@Override
public CommandResult execute(CommandSource src, CommandContext args)
        throws CommandException {
    Optional<String> subcmd =
            args.<String> getOne(Texts.toPlain(LEFTOVERS_KEY));
    if (subcmd.isPresent()) {
        String[] parts = subcmd.get().split(" ", 2);
        Optional<CommandCallable> callable =
                Optional.ofNullable(HIDDEN_CHILDREN.get(parts[0]));
        if (callable.isPresent()) {
            return callable.get().process(src, parts.length > 1 ? parts[1] : "");
        }
    }
    src.sendMessage(Texts
            .of("Not a command: " + subcmd.orElse("literally nothing")));
    return CommandResult.success();
}
 
开发者ID:kenzierocks,项目名称:Annointment,代码行数:18,代码来源:MasterCommand.java

示例3: getCommand

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
/**
 * Build a complete command hierarchy
 * @return
 */
public static CommandSpec getCommand() {
    ImmutableMap.Builder<List<String>, CommandCallable> builder = ImmutableMap.builder();
    builder.put(ImmutableList.of("add"), AddKeyCommand.getCommand());
    builder.put(ImmutableList.of("remove", "del", "delete"), RemoveKeyCommand.getCommand());
    builder.put(ImmutableList.of("reload"), ReloadCommand.getCommand());
    builder.put(ImmutableList.of("?", "help"), HelpCommand.getCommand());

    return CommandSpec.builder()
        .permission("keys.use")
        .executor(new CommandExecutor() {
            @Override
            public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
                src.sendMessage(Text.of(
                    Format.heading(TextColors.GRAY, "By ", TextColors.GOLD, "viveleroi.\n"),
                    TextColors.GRAY, "IRC: ", TextColors.WHITE, "irc.esper.net #helion3\n"
                ));
                return CommandResult.empty();
            }
        })
        .children(builder.build()).build();
}
 
开发者ID:prism,项目名称:Keys,代码行数:26,代码来源:KeysCommands.java

示例4: callable

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
public CommandCallable callable() {
        return CommandSpec.builder()
                .description(Text.of("Teleport to another world"))
                .permission("world.command.create")
                .arguments(seq(onlyOne(string(Text.of(ARG_NAME)))))
/*

            .arguments(GenericArguments.optional(GenericArguments.string(Text.of("name"))), GenericArguments.flags()
                    .valueFlag(GenericArguments.catalogedElement(Text.of("dimensionType"), DimensionType.class), "d")
                    .valueFlag(GenericArguments.catalogedElement(Text.of("generatorType"), GeneratorType.class), "g")
                    .valueFlag(GenericArguments.catalogedElement(Text.of("modifier"), WorldGeneratorModifier.class), "m")
                    .valueFlag(GenericArguments.string(Text.of("seed")), "s").buildWith(GenericArguments.none()))

             .arguments(GenericArguments.optional(GenericArguments.string(Text.of("world"))), GenericArguments.optional(GenericArguments.catalogedElement(Text.of("dimensionType"), DimensionType.class)),
                    GenericArguments.optional(GenericArguments.catalogedElement(Text.of("generatorType"), GeneratorType.class)), GenericArguments.optional(GenericArguments.catalogedElement(Text.of("modifier"), WorldGeneratorModifier.class)))

 */
                .executor(this)
                .build();
    }
 
开发者ID:vorburger,项目名称:ch.vorburger.minecraft.osgi,代码行数:21,代码来源:CreateWorldCommand.java

示例5: toCommandCallable

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
/**
 * Creates a {@link CommandCallable} from a {@link SurvivalGamesCommand}.
 *
 * @param command the {@link SurvivalGamesCommand}.
 * @return a {@link CommandCallable}.
 */
static CommandCallable toCommandCallable(SurvivalGamesCommand command) {

    CommandSpec.Builder builder = CommandSpec.builder();
    builder.executor(command);
    if (command.getChildren().size() > 0) {
        // This is a parent command.
        builder.children(command.getChildren());
    } else {
        // This is a leaf command.
        builder.arguments(command.getArguments());
    }

    builder.permission(command.getPermission());
    return builder.build();
}
 
开发者ID:m0pt0pmatt,项目名称:SurvivalGames,代码行数:22,代码来源:Util.java

示例6: BaseCommand

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
protected BaseCommand(
        SurvivalGamesCommand parentCommand,
        String name,
        CommandElement arguments,
        Map<List<String>, CommandCallable> children) {
    this.parentCommand = parentCommand;
    this.aliases = Collections.singletonList(checkNotNull(name, "name"));
    this.arguments = checkNotNull(arguments, "arguments");
    this.children = checkNotNull(children, "children");
    children.forEach(
            (aliasList, element) -> {
                checkNotNull(aliasList, "aliasList");
                checkNotNull(element, "childCommand");
                aliasList.forEach(alias -> checkNotNull(alias, "alias"));
            });
}
 
开发者ID:m0pt0pmatt,项目名称:SurvivalGames,代码行数:17,代码来源:BaseCommand.java

示例7: PrintCommand

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
private PrintCommand() {
    super(
            RootCommand.getInstance(),
            "print",
            ImmutableMap.<List<String>, CommandCallable>builder()
                    .put(toEntry(PrintBoundariesCommand.getInstance()))
                    .put(toEntry(PrintCenterLocationCommand.getInstance()))
                    .put(toEntry(PrintCountDownSecondsCommand.getInstance()))
                    .put(toEntry(PrintExitVectorCommand.getInstance()))
                    .put(toEntry(PrintExitWorldNameCommand.getInstance()))
                    .put(toEntry(PrintMobSpawnAreasCommand.getInstance()))
                    .put(toEntry(PrintPlayerLimitCommand.getInstance()))
                    .put(toEntry(PrintPlayersCommand.getInstance()))
                    .put(toEntry(PrintSpawnsCommand.getInstance()))
                    .put(toEntry(PrintSurvivalGameStateCommand.getInstance()))
                    .put(toEntry(PrintWorldNameCommand.getInstance()))
                    .put(toEntry(PrintEventIntervalsCommand.getInstance()))
                    .build());
}
 
开发者ID:m0pt0pmatt,项目名称:SurvivalGames,代码行数:20,代码来源:PrintCommand.java

示例8: SetCommand

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
private SetCommand() {
    super(
            RootCommand.getInstance(),
            "set",
            ImmutableMap.<List<String>, CommandCallable>builder()
                    .put(toEntry(SetBlocksCommand.getInstance()))
                    .put(toEntry(SetBoundaryCommand.getInstance()))
                    .put(toEntry(SetCenterVectorCommand.getInstance()))
                    .put(toEntry(SetChestMidpointCommand.getInstance()))
                    .put(toEntry(SetChestRangeCommand.getInstance()))
                    .put(toEntry(SetCountDownSecondsCommand.getInstance()))
                    .put(toEntry(SetExitVectorCommand.getInstance()))
                    .put(toEntry(SetExitWorldNameCommand.getInstance()))
                    .put(toEntry(SetPlayerLimitCommand.getInstance()))
                    .put(toEntry(SetWorldNameCommand.getInstance()))
                    .build());
}
 
开发者ID:m0pt0pmatt,项目名称:SurvivalGames,代码行数:18,代码来源:SetCommand.java

示例9: ParentCommand

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
protected ParentCommand(
        SurvivalGamesCommand parentCommand,
        String name,
        Map<List<String>, CommandCallable> children) {
    super(parentCommand, name, GenericArguments.none(), children);
    chooseChildMessage =
            Text.of("Select a child command: ")
                    .concat(
                            Text.joinWith(
                                    Text.of(':'),
                                    children.keySet()
                                            .stream()
                                            .flatMap(Collection::stream)
                                            .map(Text::of)
                                            .collect(Collectors.toList())));
}
 
开发者ID:m0pt0pmatt,项目名称:SurvivalGames,代码行数:17,代码来源:ParentCommand.java

示例10: getCallable

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
@Override
    default CommandSpec getCallable() {
        CommandSpec.Builder cb = CommandSpec.builder();
        cb.executor(new ExecutorListenerWrapper(this, this));
        cb.arguments(getArguments());
        cb.permission(getPermission().get());
        cb.description(getShortDescription(null));
        cb.extendedDescription(getLongDescription(null));

        //Children
        HashMap<List<String>, CommandCallable> children = new HashMap<>();
        getChildren().forEach((cmd) -> {
            children.put(cmd.getAliases(), cmd.getCallable());
        });
        //Only HighPermCommand can have children + avoid infinite loop
        //TODO alternative
//        if (this instanceof HighPermCommand && !(this instanceof HelpSubCommand)) {
//            children.put(Arrays.asList("?", "help"), new HelpSubCommand((HighPermCommand) this).getCallable());
//        }
        //Sponge bug: If you submit an empty children list as children, sponge fucks up the children
        if (!children.isEmpty()) {
            cb.children(children);
        }

        return cb.build();
    }
 
开发者ID:Bammerbom,项目名称:UltimateCore,代码行数:27,代码来源:HighCommand.java

示例11: getCommand

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
public static CommandSpec getCommand(Game game) {
    Builder<List<String>, CommandCallable> builder = ImmutableMap.<List<String>, CommandCallable>builder();
    builder.put(ImmutableList.of("ban"), ChannelBanCommand.getCommand());
    builder.put(ImmutableList.of("force"), ChannelForceCommand.getCommand());
    builder.put(ImmutableList.of("join"), ChannelJoinCommand.getCommand());
    builder.put(ImmutableList.of("kick"), ChannelKickCommand.getCommand());
    builder.put(ImmutableList.of("leave"), ChannelLeaveCommand.getCommand());
    builder.put(ImmutableList.of("list"), ChannelListCommand.getCommand());
    builder.put(ImmutableList.of("unban"), ChannelUnbanCommand.getCommand());
    builder.put(ImmutableList.of("help", "?"), ChannelHelpCommand.getCommand());

    return CommandSpec.builder().executor((src, args) -> {
        src.sendMessage(Text.of(Format.heading(TextColors.GRAY, "By ", TextColors.GOLD, "viveleroi.\n"),
                TextColors.GRAY, "Help: ", TextColors.WHITE, "/ch ?\n", TextColors.GRAY, "IRC: ",
                TextColors.WHITE, "irc.esper.net #helion3"));
        return CommandResult.empty();
    }).children(builder.build()).build();
}
 
开发者ID:prism,项目名称:Darmok,代码行数:19,代码来源:ChannelCommands.java

示例12: getCommand

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
public static CommandSpec getCommand() {
    ImmutableMap.Builder<List<String>, CommandCallable> builder = ImmutableMap.<List<String>, CommandCallable>builder();
    builder.put(ImmutableList.of("reload"), ReloadCommand.getCommand());

    return CommandSpec.builder().executor((src, args) -> {
        src.sendMessage(Text.of(Format.heading(TextColors.GRAY, "By ", TextColors.GOLD, "viveleroi.\n"),
            TextColors.GRAY, "IRC: ",
            TextColors.WHITE, "irc.esper.net #prism"));
        return CommandResult.empty();
    }).children(builder.build()).build();
}
 
开发者ID:prism,项目名称:Bedrock,代码行数:12,代码来源:BedrockCommands.java

示例13: getCommand

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
public static CommandSpec getCommand() {
    ImmutableMap.Builder<List<String>, CommandCallable> builder = ImmutableMap.<List<String>, CommandCallable>builder();
    builder.put(ImmutableList.of("difficulty"), DifficultyCommand.getCommand());

    return CommandSpec.builder().executor((src, args) -> {
        return CommandResult.empty();
    }).children(builder.build()).build();
}
 
开发者ID:prism,项目名称:Bedrock,代码行数:9,代码来源:WorldCommand.java

示例14: callable

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
public CommandCallable callable() {
    return CommandSpec.builder()
            .description(Text.of("rename a world"))
            .permission("world.command.rename")
            .arguments(seq(onlyOne(world(Text.of(ARG_WORLD))), onlyOne(string(Text.of(ARG_NEW_NAME)))))
            .executor(this)
            .build();
}
 
开发者ID:vorburger,项目名称:ch.vorburger.minecraft.osgi,代码行数:9,代码来源:RenameWorldCommand.java

示例15: callable

import org.spongepowered.api.command.CommandCallable; //导入依赖的package包/类
public CommandCallable callable() {
    return CommandSpec.builder()
            .description(Text.of("Teleport to another world"))
            .permission("world.command.delete")
            .arguments(onlyOne(world(Text.of(ARG_WORLD))))
            .executor(this)
            .build();
}
 
开发者ID:vorburger,项目名称:ch.vorburger.minecraft.osgi,代码行数:9,代码来源:DeleteWorldCommand.java


注:本文中的org.spongepowered.api.command.CommandCallable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。